java -- while循环拆分性能测试程序
来源:互联网 发布:mac下载百度云太慢 编辑:程序博客网 时间:2024/06/09 15:14
public class SimpleTest {
// 包含打印操作//100000 658 1061 1.6//1000000 5576 5073 0.9// 纯加操作//100000 4 6 1-1.5//100000 15 27 1.8//10000000 33 66 2.0public static void main(String[] args) { final int N = 10000000; List<Integer> list = new ArrayList<>(); for (int i = 0; i < N; i++) { list.add(i); } TimeWatcher watcher = new TimeWatcher(); long sum1 = 0; long sum11 = 0; Iterator<Integer> it = list.iterator(); while (it.hasNext()) { int i = it.next(); sum11 += i; sum1 += i; } long firstInterval = watcher.interval(); long sum2 = 0; long sum22 = 0; Iterator<Integer> it2 = list.iterator(); while (it2.hasNext()) { int i = it2.next(); sum2 += i; } it2 = list.iterator(); while (it2.hasNext()) { int i = it2.next(); sum22 += i; } long secondInterval = watcher.interval(); System.out.println(firstInterval); System.out.println(secondInterval); System.out.println(1.0 * secondInterval / firstInterval);}
}
阅读全文
0 0
- java -- while循环拆分性能测试程序
- Java程序性能测试
- Java程序性能测试
- Java程序性能测试
- SQLSERVER 拆分拼接字符串,WHILE循环输出
- java for/foreach/while 3种循环性能比较
- JAVA程序性能测试方法
- while和do...while循环测试总结
- java 中for循环的性能测试
- JAVA-while循环语句
- Java 中的while循环
- java 中的while循环
- 双重while循环测试代码
- Java 循环结构for、do...while、while
- Java学习-循环(while&do-while)
- Java循环for, while和do...while
- Java while,do while, for 循环浅析
- java:for while do while循环
- C语言笔记(关键字)
- React 条件渲染 if
- tensorflow练习11:语音识别程序
- Java中的堆和栈
- 【java面试题】2017.11.17
- java -- while循环拆分性能测试程序
- 数据库分库分表(sharding)(一)——基本思想、拆分策略和拆分所带来的问题
- JMeter源码导入到Intellij IDEA
- #include <algorithm>中sort的一般用法
- ES6_let
- 函数的调用Fact()
- memcache的工作原理
- 免费馅饼dp
- 01-复杂度2 Maximum Subsequence Sum