• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package test1;
2 
3 class BenchProceedNew2 {
4 }
5 
6 class BenchProceedNew3 {
7     int p, q;
BenchProceedNew3(int i, int j)8     BenchProceedNew3(int i, int j) {
9         p = i; q = j;
10     }
11 }
12 
13 public class BenchProceedNew {
14     public static final int N = 10000000;
15     Object result0;
16 
org0()17     public int org0() {
18         long time = System.currentTimeMillis();
19         Object obj = null;
20         for (int i = N; i > 0; --i)
21             obj = new BenchProceedNew2();
22 
23         long time2 = System.currentTimeMillis();
24         result0 = obj;
25         return (int)(time2 - time);
26     }
27 
jvst0()28     public int jvst0() {
29         long time = System.currentTimeMillis();
30         Object obj = null;
31         for (int i = N; i > 0; --i)
32             obj = new BenchProceedNew2();
33 
34         long time2 = System.currentTimeMillis();
35         result0 = obj;
36         return (int)(time2 - time);
37     }
38 
org2()39     public int org2() {
40         long time = System.currentTimeMillis();
41         Object obj = null;
42         for (int i = N; i > 0; --i)
43             obj = new BenchProceedNew3(i, i);
44 
45         long time2 = System.currentTimeMillis();
46         result0 = obj;
47         return (int)(time2 - time);
48     }
49 
jvst2()50     public int jvst2() {
51         long time = System.currentTimeMillis();
52         Object obj = null;
53         for (int i = N; i > 0; --i)
54             obj = new BenchProceedNew3(i, i);
55 
56         long time2 = System.currentTimeMillis();
57         result0 = obj;
58         return (int)(time2 - time);
59     }
60 
main(String[] args)61     public static void main(String[] args) throws Exception {
62         BenchProceedNew bp = new BenchProceedNew();
63         System.out.println("iteration " + N);
64         System.out.println("org0 (msec) " + bp.org0());
65         System.out.println("jvst0 (msec) " + bp.jvst0());
66         System.out.println("org2 (msec) " + bp.org2());
67         System.out.println("jvst2 (msec) " + bp.jvst2());
68 
69         System.out.println("org0 (msec) " + bp.org0());
70         System.out.println("jvst0 (msec) " + bp.jvst0());
71         System.out.println("org2 (msec) " + bp.org2());
72         System.out.println("jvst2 (msec) " + bp.jvst2());
73     }
74 }
75