Package: timesup
timesup🚧 There's no source code available yet. Stay tuned.Library that handles all boilerplate when it comes to measuring performance and showcasing the difference between results.Why?I was tired of writing benchmarks that not only measured performance, but also output it in an accessible and intuitive way (like this one), but also easy to reproduce.
So I decided to abstract all that away so the only thing left is to write the actual code you want to measure.I believe that by making benchmarking more accessible (and fun), I can create incentive to build faster software.FeaturesOutput is a Python code that contains the benchmark itself and ready to be publishedEffortless comparisons of resultsCompare current implementation to one in any given git revisionCompare interpreted CPython code to compiled code it produces via cython or mypycProfiling support for expressionsHTML output for viewing individual profiling results by expanding expressionsAutomatically selects the appropriate number of runs and repeats, if they weren't providedOut-of-the-box support for multiline expressionsShowcaseAll snippets are self-containedComparing within the same processcat benchmark.pyimportcopyimportduperimporttimesup@timesup.it(number=100000,repeats=3)defduper_vs_deepcopy():x={"a":1,"b":[(1,2,3),(4,5,6)],"c":[]}# icopy.deepcopy(x)# t deepcopydup=duper.Duper(x)# t duper_init deepcopydup.deep()# t duper deepcopypython benchmark.pyimportcopyimportduperimporttimesup@timesup.it(number=100000,repeats=3)defreconstruction():x={"a":1,"b":[(1,2,3),(4,5,6)],"c":[]}copy.deepcopy(x)# ~0.00643 ms (deepcopy)dup=duper.Duper(x)# ~0.00009 ms (duper_init): 69.44 times faster than deepcopydup.deep()# ~0.00014 ms (duper): 44.76 times faster than deepcopyInterpreted vs compiled codecat fib.pydeffib(n:int)->int:ifn<=1:returnnelse:returnfib(n-2)+fib(n-1)mypyc fib.pybuilding 'compiled_test' extension
...
copying build/lib.macosx-12.0-arm64-cpython-310/fib.cpython-310-darwin.so ->cat benchmark.pyimporttimesupfromfibimportfib@timesup.compare(to_interpreted=True)defcpython_vs_mypyc():fib(32)python benchmark.pyimporttimesupfromfibimportfib@timesup.compare(to_interpreted=True)defcpython_vs_mypyc():fib(32)# ~510.73292 ms (interpreted)#|_________ # ~21.72464 ms (compiled): 23.51 times faster than interpretedExisting vs new codeConsider you're trying to improve performance ofapp.used_to_be_slowfunction.It's crucial to have a baseline that you can compare your changes to.By allowing to pass a target revision that changes need to be compared to,timesup:removes the need to capture the baseline beforehandsince baseline is calculated each time automatically, you're not limited to the input you've got your baseline results withcreates a perfect code snippet to include in PR with the changes ✨this snipped can be run by any of reviewers without them needing to manually download any benchmarks, measuring the baseline and testing the resultscat benchmark.pyimporttimesupfromappimportused_to_be_slow@timesup.compare(to_revision="main")defmeasure_improvement():used_to_be_slow()python benchmark.pyimporttimesupfromappimportused_to_be_slow@timesup.compare(to_revision="main")defmeasure_improvement():used_to_be_slow()# ~0.00106 ms (34dc8225)#|___________________ # ~0.00035 ms (changes): 2.99 times faster than 34dc8225🚧 StatusIf you have any feedback, you canopen the issue, or  contact me directly viabobronium@gmail.comorTelegram.