Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
% time ./miniruby -e'a=100;i=0;while i<0xffffff;i+=1;a*=557;a+=2;a%=100000;end'
./miniruby -e'a=100;i=0;while i<0xffffff;i+=1;a*=557;a+=2;a%=100000;end' 2.64s user 0.01s system 99% cpu 2.649 total
% ruby -e'puts RubyVM::InstructionSequence.compile(%q{a=100;i=0;while i<0xffffff;i+=1;a*=557;a+=2;a%=
100000;end}).disasm'
== disasm: #<ISeq:<compiled>@<compiled>>================================
== catch table
| catch type: break st: 0015 ed: 0060 sp: 0000 cont: 0060
| catch type: next st: 0015 ed: 0060 sp: 0000 cont: 0012
| catch type: redo st: 0015 ed: 0060 sp: 0000 cont: 0015
|------------------------------------------------------------------------
cal table (size: 3, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 3] a [ 2] i
0000 trace 1 ( 1)
0002 putobject 100
0004 setlocal_OP__WC__0 3
0006 putobject_OP_INT2FIX_O_0_C_
0007 setlocal_OP__WC__0 2
0009 jump 50
0011 putnil
0012 pop
0013 jump 50
0015 getlocal_OP__WC__0 2
0017 putobject_OP_INT2FIX_O_1_C_
0018 opt_plus <callinfo!mid:+, argc:1, ARGS_SIMPLE>, <callcache>
0021 setlocal_OP__WC__0 2
0023 getlocal_OP__WC__0 3
0025 putobject 557
0027 opt_mult <callinfo!mid:*, argc:1, ARGS_SIMPLE>, <callcache>
0030 setlocal_OP__WC__0 3
0032 getlocal_OP__WC__0 3
0034 putobject 2
0036 opt_plus <callinfo!mid:+, argc:1, ARGS_SIMPLE>, <callcache>
0039 setlocal_OP__WC__0 3
0041 getlocal_OP__WC__0 3
0043 putobject 100000
0045 opt_mod <callinfo!mid:%, argc:1, ARGS_SIMPLE>, <callcache>
0048 setlocal_OP__WC__0 3
0050 getlocal_OP__WC__0 2
0052 putobject 16777215
0054 opt_lt <callinfo!mid:<, argc:1, ARGS_SIMPLE>, <callcache>
0057 branchif 15
0059 putnil
0060 leave
% time ./miniruby -e'a=100;i=0;while i<0xffffff;i+=1;a=(a*557+2)%100000;end'
./miniruby -e'a=100;i=0;while i<0xffffff;i+=1;a=(a*557+2)%100000;end' 1.32s user 0.00s system 99% cpu 1.325 total
% ruby -e'puts RubyVM::InstructionSequence.compile(%q{a=100;i=0;while i<0xffffff;i+=1;a=(a*557+2)%100000;end}).disasm'
== disasm: #<ISeq:<compiled>@<compiled>>================================
== catch table
| catch type: break st: 0015 ed: 0052 sp: 0000 cont: 0052
| catch type: next st: 0015 ed: 0052 sp: 0000 cont: 0012
| catch type: redo st: 0015 ed: 0052 sp: 0000 cont: 0015
|------------------------------------------------------------------------
local table (size: 3, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 3] a [ 2] i
0000 trace 1 ( 1)
0002 putobject 100
0004 setlocal_OP__WC__0 3
0006 putobject_OP_INT2FIX_O_0_C_
0007 setlocal_OP__WC__0 2
0009 jump 42
0011 putnil
0012 pop
0013 jump 42
0015 getlocal_OP__WC__0 2
0017 putobject_OP_INT2FIX_O_1_C_
0018 opt_plus <callinfo!mid:+, argc:1, ARGS_SIMPLE>, <callcache>
0021 setlocal_OP__WC__0 2
0023 getlocal_OP__WC__0 3
0025 putobject 557
0027 opt_mult <callinfo!mid:*, argc:1, ARGS_SIMPLE>, <callcache>
0030 putobject 2
0032 opt_plus <callinfo!mid:+, argc:1, ARGS_SIMPLE>, <callcache>
0035 putobject 100000
0037 opt_mod <callinfo!mid:%, argc:1, ARGS_SIMPLE>, <callcache>
0040 setlocal_OP__WC__0 3
0042 getlocal_OP__WC__0 2
0044 putobject 16777215
0046 opt_lt <callinfo!mid:<, argc:1, ARGS_SIMPLE>, <callcache>
0049 branchif 15
0051 putnil
0052 leave
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.