[{"data":1,"prerenderedAt":114},["ShallowReactive",2],{"blog-post-hyperfine-benchmark-python-script":3,"recent-posts":70},{"id":4,"uid":5,"url":6,"type":7,"href":8,"tags":9,"first_publication_date":10,"last_publication_date":10,"slugs":11,"linked_documents":13,"lang":14,"alternate_languages":15,"data":16},"av7XERIAACcAmDy5","hyperfine-benchmark-python-script",null,"blog_posts","https:\u002F\u002Fmarks-personal-website.cdn.prismic.io\u002Fapi\u002Fv2\u002Fdocuments\u002Fsearch?ref=awdlAxIAACcAJjXm&q=%5B%5B%3Ad+%3D+at%28document.id%2C+%22av7XERIAACcAmDy5%22%29+%5D%5D",[],"2026-11-25T22:45:23+0000",[12],"hyperfine-how-to-benchmark-a-python-script",[],"en-us",[],{"title":17,"date":23,"description":24,"image":29,"content":39},[18],{"type":19,"text":20,"spans":21,"direction":22},"heading1","Hyperfine: How to Benchmark a Python Script",[],"ltr","2026-11-25",[25],{"type":26,"text":27,"spans":28,"direction":22},"heading2","Learn how to benchmark a Python script using hyperfine",[],{"dimensions":30,"alt":20,"copyright":6,"url":33,"id":34,"edit":35},{"width":31,"height":32},1280,720,"https:\u002F\u002Fimages.prismic.io\u002Fmarks-personal-website\u002FwHSLchMR8qvd2IUQ_hyperfine-benchmark-python-script.png?auto=format,compress","wHSLchMR8qvd2IUQ",{"x":36,"y":36,"zoom":37,"background":38},0,1,"transparent",[40,44,48,51,54,57,60,63,67],{"type":41,"text":42,"spans":43,"direction":22},"paragraph","Before we start, make sure you have hyperfine installed on your computer and your Python script ready in a folder. If you don't have it yet, run this command:",[],{"type":45,"text":46,"spans":47,"direction":22},"preformatted","brew install hyperfine",[],{"type":41,"text":49,"spans":50,"direction":22},"First, open your terminal and navigate to the folder that has your script. To benchmark it, run this command:",[],{"type":45,"text":52,"spans":53,"direction":22},"hyperfine \"python3 script.py\"",[],{"type":41,"text":55,"spans":56,"direction":22},"Just remember to replace \u003Ccode>script.py\u003C\u002Fcode> with your actual filename and keep the whole command inside quotes. Hyperfine runs the script over and over, so give it a few seconds. Then it shows the average time, the spread and the memory use.",[],{"type":41,"text":58,"spans":59,"direction":22},"For steadier numbers, add the \u003Ccode>--warmup\u003C\u002Fcode> option. It does a few practice runs first, so the cold start doesn't skew your results:",[],{"type":45,"text":61,"spans":62,"direction":22},"hyperfine --warmup 3 \"python3 script.py\"",[],{"type":64,"oembed":65},"embed",{"embed_url":66,"type":64},"",{"type":41,"text":68,"spans":69,"direction":22},"One more tip: hyperfine times the whole process, so every run includes the time Python takes to start. For tiny functions, use the built in \u003Ccode>timeit\u003C\u002Fcode> module instead.",[],{"results":71,"page":37,"results_per_page":112,"results_size":112,"total_results_size":113,"total_pages":37},[72,74,93],{"id":4,"uid":5,"url":6,"type":7,"href":8,"tags":9,"first_publication_date":10,"last_publication_date":10,"slugs":11,"linked_documents":13,"lang":14,"alternate_languages":15,"data":73},{"image":29,"title":17},{"id":75,"uid":76,"url":6,"type":7,"href":77,"tags":78,"first_publication_date":10,"last_publication_date":10,"slugs":79,"linked_documents":81,"lang":14,"alternate_languages":82,"data":83},"av7XDxIAACkAmDyy","imagemagick-optimize-images","https:\u002F\u002Fmarks-personal-website.cdn.prismic.io\u002Fapi\u002Fv2\u002Fdocuments\u002Fsearch?ref=awdlAxIAACcAJjXm&q=%5B%5B%3Ad+%3D+at%28document.id%2C+%22av7XDxIAACkAmDyy%22%29+%5D%5D",[],[80],"imagemagick-how-to-optimize-images",[],[],{"image":84,"title":90},{"dimensions":85,"alt":86,"copyright":6,"url":87,"id":88,"edit":89},{"width":31,"height":32},"ImageMagick: How to Optimize Images","https:\u002F\u002Fimages.prismic.io\u002Fmarks-personal-website\u002FUCjpRnL5HVuoeJpz_imagemagick-optimize-images.png?auto=format,compress","UCjpRnL5HVuoeJpz",{"x":36,"y":36,"zoom":37,"background":38},[91],{"type":19,"text":86,"spans":92,"direction":22},[],{"id":94,"uid":95,"url":6,"type":7,"href":96,"tags":97,"first_publication_date":10,"last_publication_date":10,"slugs":98,"linked_documents":100,"lang":14,"alternate_languages":101,"data":102},"av7XFBIAAC0AmDzM","hyperfine-export-results-csv","https:\u002F\u002Fmarks-personal-website.cdn.prismic.io\u002Fapi\u002Fv2\u002Fdocuments\u002Fsearch?ref=awdlAxIAACcAJjXm&q=%5B%5B%3Ad+%3D+at%28document.id%2C+%22av7XFBIAAC0AmDzM%22%29+%5D%5D",[],[99],"hyperfine-how-to-export-results-to-csv",[],[],{"image":103,"title":109},{"dimensions":104,"alt":105,"copyright":6,"url":106,"id":107,"edit":108},{"width":31,"height":32},"Hyperfine: How to Export Results to CSV","https:\u002F\u002Fimages.prismic.io\u002Fmarks-personal-website\u002FEnLW4_wsg-hN24G5_hyperfine-export-results-csv.png?auto=format,compress","EnLW4_wsg-hN24G5",{"x":36,"y":36,"zoom":37,"background":38},[110],{"type":19,"text":105,"spans":111,"direction":22},[],3,94,1795646747353]