Pythonでの処理時間計測

投稿日: 2022-05-21 09:39:12

Python処理時間計測

Pythonを速くするTIPS集(計測・ビルドインの各機能・Cython・Numba・etc) - Qiita

line_profiler

pip install line_profiler
profiler = line_profiler.LineProfiler() 
profiler.add_function(sample_func)
_ = profiler.runcall(sample_func)
profiler.print_stats()

pypy開発の基礎知識を入門者向けに解説!Pythonと比較した処理速度の速さとは?pypyのインストール方法も紹介- ITフリーランスエンジニア案件ならA-STAR(エースター)

timeit モジュール

python -m timeit “処理”

Benchmarker

Benchmarker · PyPI (Released: Dec 17, 2014)

pytest-benchmark

Welcome to pytest-benchmark’s documentation! — pytest-benchmark 3.4.1 documentation

Jupyter上での計測するマジックコマンド

%timeitのマジックコマンド

%timeit [i for i in range(3000000)]

%prunのマジックコマンド

%%prun
sample_func_4()