Bystroushaak's blog / English section / Programming / tinySelf / Simple while benchmark 2019.01.06

Simple while benchmark 2019.01.06

I've decided to add some benchmarks just for my own usage to measure whether things improved when I change something or not.

Benchmark of the tinySelf while loop:

(|
    benchmark = (| i <- 0. |
        [i < 10000] whileTrue: [
            i: i + 1.
        ].
    ).

    run_benchmark = (| start_time. end_time. |
        primitives interpreter runScript: 'objects/stdlib.tself'.

        start_time: primitives time timestamp.
        benchmark.
        end_time: primitives time timestamp.


        end_time - start_time asString + '\n' print.
    ).
|) run_benchmark.

10 000 while cycles

Version Time (in Seconds)
Interpreted under Python 2.7 25.31
Interpreted under Pypy 2.7 0.7
RPython (without JIT) 0.16

1 000 000 while cycles

Version Time (in Seconds)
Interpreted under Python 2.7 2583.2
Interpreted under Pypy 2.7 30.25
RPython (without JIT) 16.26

This is obviously quite slow, but at least it now gives me tool to measure how slow and how much was the speed improved with optimizations.

Obvious optimization will be turning JIT on, using rpythons unboxed integers and also caching of the slot lookups.

Become a Patron