Skip to content

Instantly share code, notes, and snippets.

@jruby
Created October 13, 2009 22:12
Show Gist options
  • Save jruby/209607 to your computer and use it in GitHub Desktop.
Save jruby/209607 to your computer and use it in GitHub Desktop.
~/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment