On 2017-02-07 08:50, Vibhav Pant wrote: > On Tue, Feb 7, 2017 at 12:00 AM, Stefan Monnier > wrote: >>> The following patch adds support for a new op `switch` to the Emacs >>> bytecode VM and compiler. >> >> I guess the motivation is to speed up some code. >> Did you make any measurements to see what kind of effect it has? > > The attached benchmark code took 9.409541956 seconds when compiled > without switch, > and 0.20807168799999998 seconds (97% speedup) when compiled with switch. It > generates a cond clause with a thousand clauses comparing a variable > with random integer values, with the last clause containing the actual > value. However, > since it's a synthetic benchmark, real world code should be better indicator of > performance improvement. I've attached another benchmark, which evaluates arithmetic expressions. On this, byte-switch seems to be a bit slower: $ rm -f *.elc; emacs-byte-switch -Q --batch --eval '(byte-compile-file "eval-expr.el")'; time emacs-byte-switch -Q --batch -L . -l benchmark-expr.el real 0m4.193s user 0m4.188s sys 0m0.000s $ rm -f *.elc; emacs-master -Q --batch --eval '(byte-compile-file "eval-expr.el")'; time emacs-master -Q --batch -L . -l benchmark-expr.el real 0m3.956s user 0m3.944s sys 0m0.008s The timings fluctuate quite a bit, but the byte-switch branch seems to be about 5-7% slower. Hopefully linear-scan hash tables will make things much faster :) Thanks for your work on this! Cheers, Clément.