java 计时工具 用户性能测试
2017-11-16 12:38
411 查看
/**
* @Description: 计时工具:单位毫秒
* 用于性能测试
* @author Adobe Chow
* @date 2017年11月16日 上午11:50:18
*
*/
public class TimerUtils {
private static long startTime = -1;
/**
* @Description: 开始计时
*/
public static void start(){
startTime = System.currentTimeMillis();
}
/**
* @Description: 关闭并返回时间间隔
*/
public static long stop(){
if(startTime<0){
System.out.println("start开关未开启 ");
return startTime;
}
long timeSpace = System.currentTimeMillis()-startTime;
System.out.println("时间间隔: "+timeSpace+" 毫秒");
return timeSpace;
}
public static void main(String[] args) {
//开始计时
TimerUtils.start();
String str = "";
for (int i = 0; i < 10000; i++) {
str = str + "11"+i;
}
//关闭并返回时间间隔
TimerUtils.stop();
}
}
控制台输出:
* @Description: 计时工具:单位毫秒
* 用于性能测试
* @author Adobe Chow
* @date 2017年11月16日 上午11:50:18
*
*/
public class TimerUtils {
private static long startTime = -1;
/**
* @Description: 开始计时
*/
public static void start(){
startTime = System.currentTimeMillis();
}
/**
* @Description: 关闭并返回时间间隔
*/
public static long stop(){
if(startTime<0){
System.out.println("start开关未开启 ");
return startTime;
}
long timeSpace = System.currentTimeMillis()-startTime;
System.out.println("时间间隔: "+timeSpace+" 毫秒");
return timeSpace;
}
public static void main(String[] args) {
//开始计时
TimerUtils.start();
String str = "";
for (int i = 0; i < 10000; i++) {
str = str + "11"+i;
}
//关闭并返回时间间隔
TimerUtils.stop();
}
}
控制台输出:
相关文章推荐
- JAVA 性能测试工具 JMeter 介绍
- Java 性能测试工具 JMH
- mysql性能测试工具之tpcc-mysql 及 mysql 用户管理和权限设置
- [java]性能测试分析工具EclipseProfiler
- java中Json工具的用法比较与性能测试
- java性能测试工具
- 常用Java性能测试工具的分析与对比
- java性能测试分析工具
- java性能、负载、压力测试工具
- 常用Java性能测试工具的分析与对比
- J Optimizer-Java性能测试分析工具
- Java常用的性能测试工具记录
- 常用Java性能测试工具的分析与对比
- java性能测试工具
- 使用多线程模拟多用户并发访问一个或多个tomcat,测试性能 java
- Java性能/负载/压力测试工具
- JAVA 性能测试工具 JMeter 介绍
- Java列表对象的性能分析和测试
- SOAP协议性能测试工具—SOAP Performer 0.1正式发布
- 服务器性能测试典型工具介绍