这是一个简单的性能管理模块,可以自由添加指标和每分钟输出日志
<repositories>
<repository>
<id>tahiti-nexus-snapshots</id>
<name>Tahiti NEXUS</name>
<url>http://sse.tongji.edu.cn/tahiti/nexus/content/groups/public</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>wheellllll</groupId>
<artifactId>PerformanceManager</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>从 https://github.com/Wheellllll/PerformanceManager/releases 下载最新的jar包添加到项目依赖里去
本模块是线程安全的,您可以在多个线程中对同一个指标进行更新操作
PerformanceManager pm = new PerformanceManager();LogUtils.setLogPrefix("Server"); //设置输出的文件名
LogUtils.setLogPath("./log"); //设置输出文件的路径pm.setTimeUnit(TimeUnit.SECONDS); //时间单位为秒
pm.setInitialDelay(1); //延时1秒后执行
pm.setPeriod(60); //循环周期为60秒即1分钟pm.addIndex("loginSuccess");
pm.addIndex("loginFail");pm.removeIndex("loginSuccess");pm.updateIndex("loginSuccess", 1); //loginSuccess指标加1
pm.updateIndex("loginFail", 2); //loginFail指标加2pm.start();
...
...
...pm.clear();pm.stop();Log at: 时间 指标:数值 指标:数值 ...
Log at : 2016-04-10 22:41:53 loginSuccess : 4 loginFail : 8