Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Tmp {
- static double test(Runnable runnable) {
- double start = System.currentTimeMillis();
- runnable.run();
- return (System.currentTimeMillis() - start) / 1000.0;
- }
- public static void main(String[] args) {
- final int n = 100000000;
- System.out.println(test(new Runnable() {
- public void run() {
- for(int i = 0; i < n; i++) {
- double x = Math.random();
- //System.out.println(x);
- }
- }
- }));
- System.out.println(test(new Runnable() {
- public void run() {
- double x;
- for(int i = 0; i < n; i++) {
- x = Math.random();
- //System.out.println(x);
- }
- }}));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement