scalene

scalene erstellt sehr schnell Profile für CPU und Arbeitsspeicher. Dabei ist der Overhead üblicherweise mit 10–20% sehr gering.

Installation

Linux und WSL

$ pipenv install scalene

MacOS

$ brew install --HEAD emeryberger/scalene/libscalene

Verwendung

$ pipenv run scalene test/testme.py

Alle verfügbaren Optionen könnt ihr euch anzeigen lassen mit

$ pipenv run scalene --help
scalene --help
 usage: scalene [-h] [--outfile OUTFILE] [--html] [--reduced-profile]
                [--profile-interval PROFILE_INTERVAL] [--cpu-only]
                [--profile-all] [--profile-only PROFILE_ONLY]
                [--use-virtual-time]
                [--cpu-percent-threshold CPU_PERCENT_THRESHOLD]
                [--cpu-sampling-rate CPU_SAMPLING_RATE]
                [--malloc-threshold MALLOC_THRESHOLD]

 Scalene: a high-precision CPU and memory profiler.
             https://github.com/emeryberger/scalene
             % scalene yourprogram.py

 optional arguments:
   -h, --help            show this help message and exit
   --outfile OUTFILE     file to hold profiler output (default: stdout)
   --html                output as HTML (default: text)
   --reduced-profile     generate a reduced profile, with non-zero lines only (default: False).
   --profile-interval PROFILE_INTERVAL
                         output profiles every so many seconds.
   --cpu-only            only profile CPU time (default: profile CPU, memory, and copying)
   --profile-all         profile all executed code, not just the target program (default: only the target program)
   --profile-only PROFILE_ONLY
                         profile only code in files that contain the given string (default: no restrictions)
   --use-virtual-time    measure only CPU time, not time spent in I/O or blocking (default: False)
   --cpu-percent-threshold CPU_PERCENT_THRESHOLD
                         only report profiles with at least this percent of CPU time (default: 1%)
   --cpu-sampling-rate CPU_SAMPLING_RATE
                         CPU sampling rate (default: every 0.01s)
   --malloc-threshold MALLOC_THRESHOLD
                         only report profiles with at least this many allocations (default: 100)