Bystroushaak / tinySelf

Self-like language implemented in the RPython language toolkit.
29 stars 3 forks source link

Test rewrite to enumerate #101

Closed Bystroushaak closed 5 years ago

Bystroushaak commented 5 years ago

In ._put_together_parameters(), there is a for loop which may be rewritten to enumerate, try it.

Bystroushaak commented 5 years ago

Results with numeric for loop:

       1875,301253      task-clock (msec)         #    0,989 CPUs utilized          
                 4      context-switches          #    0,002 K/sec                  
                 1      cpu-migrations            #    0,001 K/sec                  
             1 557      page-faults               #    0,830 K/sec                  
     5 610 477 226      cycles                    #    2,992 GHz                    
    15 157 268 352      instructions              #    2,70  insn per cycle         
     3 018 035 781      branches                  # 1609,361 M/sec                  
         3 168 333      branch-misses             #    0,10% of all branches        

       1,895898693 seconds time elapsed

Results with enumerate:

       1915,782693      task-clock (msec)         #    0,991 CPUs utilized          
                 4      context-switches          #    0,002 K/sec                  
                 0      cpu-migrations            #    0,000 K/sec                  
             1 479      page-faults               #    0,772 K/sec                  
     5 718 264 310      cycles                    #    2,985 GHz                    
    15 292 051 465      instructions              #    2,67  insn per cycle         
     3 037 764 105      branches                  # 1585,652 M/sec                  
         3 034 056      branch-misses             #    0,10% of all branches        

       1,933299059 seconds time elapsed

Results with zip:

[translation:ERROR] TyperError: don't know about built-in function <built-in function zip>
.. (tinySelf.vm.interpreter:178)Interpreter._put_together_parameters__next
.. block@133[parameter_names_0...] with 1 exits
.. v232 = simple_call((builtin_function zip), parameter_names_0, parameters_0)
Bystroushaak commented 5 years ago

Rewritten to while cycle:

       1912,635985      task-clock (msec)         #    0,990 CPUs utilized          
                 5      context-switches          #    0,003 K/sec                  
                 1      cpu-migrations            #    0,001 K/sec                  
             1 496      page-faults               #    0,782 K/sec                  
     5 629 498 244      cycles                    #    2,943 GHz                    
    15 140 028 836      instructions              #    2,69  insn per cycle         
     3 015 765 542      branches                  # 1576,759 M/sec                  
         3 244 769      branch-misses             #    0,11% of all branches        

       1,931796212 seconds time elapsed
Bystroushaak commented 5 years ago

Closed from Marseille :)