Last active
December 28, 2017 03:36
-
-
Save obriencj/300e43819ba2f75376df48d4461e7c4b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maybe:python-sibilant siege$ sibsampl timeit --of 1000 --times 1000 | |
calculating fibonacci of 1000 | |
answer is 43466557686937456435688527675040625802564660517371780402481729089536555417949051890403879840079255169295922593080322634775209689623239873322471161642996440906533187938298969649928516003704476137795166849228875 | |
maximum recursion depth exceeded in comparison | |
maximum recursion depth exceeded | |
fibonacci with TCR over 1000 loops -> 0.6279 seconds (0.26% runtime) | |
fibonacci with TCO over 1000 loops -> 0.9989 seconds (0.41% runtime) | |
fibonacci no TC over 1000 loops -> 0.0000 seconds (0.00% runtime) | |
fibonacci LRU cache over 1000 loops -> 0.0000 seconds (0.00% runtime) | |
fibonacci loop over 1000 loops -> 0.8034 seconds (0.33% runtime) | |
maybe:python-sibilant siege$ sibsampl timeit --of 1000 --times 1000 --limit 5000 | |
calculating fibonacci of 1000 | |
answer is 43466557686937456435688527675040625802564660517371780402481729089536555417949051890403879840079255169295922593080322634775209689623239873322471161642996440906533187938298969649928516003704476137795166849228875 | |
increased recursion limit from 1000 to 6000 | |
fibonacci with TCR over 1000 loops -> 0.6156 seconds (0.13% runtime) | |
fibonacci with TCO over 1000 loops -> 0.9852 seconds (0.21% runtime) | |
fibonacci no TC over 1000 loops -> 0.9811 seconds (0.21% runtime) | |
fibonacci LRU cache over 1000 loops -> 1.3128 seconds (0.28% runtime) | |
fibonacci loop over 1000 loops -> 0.7967 seconds (0.17% runtime) | |
maybe:python-sibilant siege$ python3 -X sibilant.ctco=False `which sibsampl` timeit --of 1000 --times 1000 --limit 5000 | |
calculating fibonacci of 1000 | |
answer is 43466557686937456435688527675040625802564660517371780402481729089536555417949051890403879840079255169295922593080322634775209689623239873322471161642996440906533187938298969649928516003704476137795166849228875 | |
increased recursion limit from 1000 to 6000 | |
fibonacci with TCR over 1000 loops -> 0.6243 seconds (0.09% runtime) | |
fibonacci with TCO over 1000 loops -> 3.1136 seconds (0.45% runtime) | |
fibonacci no TC over 1000 loops -> 1.0187 seconds (0.15% runtime) | |
fibonacci LRU cache over 1000 loops -> 1.3525 seconds (0.20% runtime) | |
fibonacci loop over 1000 loops -> 0.8204 seconds (0.12% runtime) | |
maybe:python-sibilant siege$ python3 -X sibilant.ctco=True `which sibsampl` timeit --of 5000 --times 1000 --limit 15000 | |
calculating fibonacci of 5000 | |
answer is 3878968454388325633701916308325905312082127714646245106160597214895550139044037097010822916462210669479293452858882973813483102008954982940361430156911478938364216563944106910214505634133706558656238254656700712525929903854933813928836378347518908762970712033337052923107693008518093849801803847813996748881765554653788291644268912980384613778969021502293082475666346224923071883324803280375039130352903304505842701147635242270210934637699104006714174883298422891491273104054328753298044273676822977244987749874555691907703880637046832794811358973739993110106219308149018570815397854379195305617510761053075688783766033667355445258844886241619210553457493675897849027988234351023599844663934853256411952221859563060475364645470760330902420806382584929156452876291575759142343809142302917491088984155209854432486594079793571316841692868039545309545388698114665082066862897420639323438488465240988742395873801976993820317174208932265468879364002630797780058759129671389634214252579116872755600360311370547754724604639987588046985178408674382863125 | |
increased recursion limit from 1000 to 16000 | |
fibonacci with TCR over 1000 loops -> 3.4535 seconds (0.11% runtime) | |
fibonacci with TCO over 1000 loops -> 5.4625 seconds (0.18% runtime) | |
fibonacci no TC over 1000 loops -> 8.9864 seconds (0.29% runtime) | |
fibonacci LRU cache over 1000 loops -> 8.6103 seconds (0.28% runtime) | |
fibonacci loop over 1000 loops -> 4.4085 seconds (0.14% runtime) | |
maybe:python-sibilant siege$ python3 -X sibilant.ctco=True `which sibsampl` timeit --of 5000 --times 1000 --limit 15000 | |
calculating fibonacci of 5000 | |
answer is 3878968454388325633701916308325905312082127714646245106160597214895550139044037097010822916462210669479293452858882973813483102008954982940361430156911478938364216563944106910214505634133706558656238254656700712525929903854933813928836378347518908762970712033337052923107693008518093849801803847813996748881765554653788291644268912980384613778969021502293082475666346224923071883324803280375039130352903304505842701147635242270210934637699104006714174883298422891491273104054328753298044273676822977244987749874555691907703880637046832794811358973739993110106219308149018570815397854379195305617510761053075688783766033667355445258844886241619210553457493675897849027988234351023599844663934853256411952221859563060475364645470760330902420806382584929156452876291575759142343809142302917491088984155209854432486594079793571316841692868039545309545388698114665082066862897420639323438488465240988742395873801976993820317174208932265468879364002630797780058759129671389634214252579116872755600360311370547754724604639987588046985178408674382863125 | |
increased recursion limit from 1000 to 16000 | |
fibonacci with TCR over 1000 loops -> 3.5020 seconds (0.11% runtime) | |
fibonacci with TCO over 1000 loops -> 5.4936 seconds (0.18% runtime) | |
fibonacci no TC over 1000 loops -> 8.9146 seconds (0.29% runtime) | |
fibonacci LRU cache over 1000 loops -> 8.7342 seconds (0.28% runtime) | |
fibonacci loop over 1000 loops -> 4.3668 seconds (0.14% runtime) |
Want to note, those times are on a 2013 MacBook Air, unplugged, at sub 50% battery life. The point isn't the absolute speeds, but rather to demonstrate the relative overhead.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is on the TCR branch (direct recursion turns into a jump 0). Note that TCR is very fast! Also note that the native TCO (from the first two runs) is fast enough now that the overhead from the trampoline is barely noticeable vs. recursion without tailcall at all!