jruby (owner)

Revisions

gist: 209607 Download_button fork
public
Public Clone URL: git://gist.github.com/209607.git
Embed All Files: show embed
Text only #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
~/projects/rubinius/benchmark/tiers/0 ➔ javap -c bm_vm2_method
Compiled from "bm_vm2_method.java"
public class bm_vm2_method extends java.lang.Object{
public bm_vm2_method();
  Code:
   0: aload_0
   1: invokespecial #1; //Method java/lang/Object."<init>":()V
   4: return
 
public static java.lang.Object m();
  Code:
   0: aconst_null
   1: areturn
 
public static void run();
  Code:
   0: iconst_0
   1: istore_0
   2: iload_0
   3: ldc #2; //int 6000000
   5: if_icmpge 46
   8: iinc 0, 1
   11: invokestatic #3; //Method m:()Ljava/lang/Object;
   14: pop
   15: invokestatic #3; //Method m:()Ljava/lang/Object;
   18: pop
   19: invokestatic #3; //Method m:()Ljava/lang/Object;
   22: pop
   23: invokestatic #3; //Method m:()Ljava/lang/Object;
   26: pop
   27: invokestatic #3; //Method m:()Ljava/lang/Object;
   30: pop
   31: invokestatic #3; //Method m:()Ljava/lang/Object;
   34: pop
   35: invokestatic #3; //Method m:()Ljava/lang/Object;
   38: pop
   39: invokestatic #3; //Method m:()Ljava/lang/Object;
   42: pop
   43: goto 2
   46: return
 
public static void main(java.lang.String[]);
  Code:
   0: iconst_0
   1: istore_1
   2: iload_1
   3: bipush 50
   5: if_icmpge 32
   8: invokestatic #4; //Method java/lang/System.currentTimeMillis:()J
   11: lstore_2
   12: invokestatic #5; //Method run:()V
   15: getstatic #6; //Field java/lang/System.out:Ljava/io/PrintStream;
   18: invokestatic #4; //Method java/lang/System.currentTimeMillis:()J
   21: lload_2
   22: lsub
   23: invokevirtual #7; //Method java/io/PrintStream.println:(J)V
   26: iinc 1, 1
   29: goto 2
   32: return
 
}
 
 
~/projects/rubinius/benchmark/tiers/0 ➔ ../../../../duby/bin/dubyc bm_vm2_method.duby
 
~/projects/rubinius/benchmark/tiers/0 ➔ javap -c bm_vm2_method
Compiled from "bm_vm2_method.duby"
public class bm_vm2_method extends java.lang.Object{
public static void main(java.lang.String[]);
  Code:
   0: iconst_0
   1: istore_1
   2: iload_1
   3: bipush 50
   5: if_icmplt 12
   8: iconst_0
   9: goto 13
   12: iconst_1
   13: ifeq 42
   16: invokestatic #21; //Method java/lang/System.currentTimeMillis:()J
   19: lstore_2
   20: invokestatic #23; //Method run:()Ljava/lang/Object;
   23: pop
   24: getstatic #27; //Field java/lang/System.out:Ljava/io/PrintStream;
   27: invokestatic #21; //Method java/lang/System.currentTimeMillis:()J
   30: lload_2
   31: lsub
   32: invokevirtual #33; //Method java/io/PrintStream.println:(J)V
   35: iload_1
   36: iconst_1
   37: iadd
   38: istore_1
   39: goto 2
   42: return
 
public static java.lang.Object m();
  Code:
   0: aconst_null
   1: areturn
 
public static java.lang.Object run();
  Code:
   0: iconst_0
   1: istore_0
   2: iload_0
   3: ldc #11; //int 6000000
   5: if_icmplt 12
   8: iconst_0
   9: goto 13
   12: iconst_1
   13: ifeq 55
   16: iload_0
   17: iconst_1
   18: iadd
   19: istore_0
   20: invokestatic #13; //Method m:()Ljava/lang/Object;
   23: pop
   24: invokestatic #13; //Method m:()Ljava/lang/Object;
   27: pop
   28: invokestatic #13; //Method m:()Ljava/lang/Object;
   31: pop
   32: invokestatic #13; //Method m:()Ljava/lang/Object;
   35: pop
   36: invokestatic #13; //Method m:()Ljava/lang/Object;
   39: pop
   40: invokestatic #13; //Method m:()Ljava/lang/Object;
   43: pop
   44: invokestatic #13; //Method m:()Ljava/lang/Object;
   47: pop
   48: invokestatic #13; //Method m:()Ljava/lang/Object;
   51: pop
   52: goto 2
   55: aconst_null
   56: areturn
 
public bm_vm2_method();
  Code:
   0: aload_0
   1: invokespecial #41; //Method java/lang/Object."<init>":()V
   4: return
 
}
 
 
~/projects/rubinius/benchmark/tiers/0 ➔ cat bm_vm2_method.java
public class bm_vm2_method {
public static Object m() {
  return null;
}
 
public static void run() {
  int i=0;
  while (i<6000000) { // benchmark loop 2
    i+=1;
    m(); m(); m(); m(); m(); m(); m(); m();
  }
}
 
public static void main(String[] args) {
  for (int i = 0; i < 50; i++) {
    long time = System.currentTimeMillis();
    run();
    System.out.println(System.currentTimeMillis() - time);
  }
}
}
 
~/projects/rubinius/benchmark/tiers/0 ➔ cat bm_vm2_method.duby
import java.lang.System
 
def m
  nil
end
 
def run
  i=0
  while i<6000000 # benchmark loop 2
    i+=1
    m; m; m; m; m; m; m; m;
  end
  nil
end
 
i = 0
while i < 50
  time = System.currentTimeMillis
  run
  puts System.currentTimeMillis - time
  i+= 1
end