Benchmark Python Snippets Online

Perfpy allows you to benchmark python snippets online and share them with other people. You can measure the performance and memory usage of code on different python versions in this sandbox environment.

The tool can compare and test the speed of 3rd-party libraries or library versions, so you can find out which is the fastest or consumes less memory between numpy, opencv, scipy and pandas for a certain function.

Packages

List packages as it's done in a requirements.txt file. Learn more

Setup

Runs before the benchmark, and it is not measured. Good place to import libraries and prepare data. Learn more

Code 1

Code 2

Code 3

Teardown

Results

Fastest

Code 2

5.87 ms

170 op/s

Speed

BenchmarkRuntime
Operations
VS
Visual
Code 25.87 ms170 op/s0.005871319056799014
Code 331.2 ms32.0 op/s0.03121881280094385
Code 136.0 ms27.7 op/s0.036041573931773506

Memory

BenchmarkPeak Memory
Score
VS
Visual
Code 21.32 MB7.111316
Code 11.57 MB6.251.19×1572
Code 33.27 MB5.992.5×3272

Output

Code 1
<string>:8: RuntimeWarning: divide by zero encountered in log2
<string>:8: RuntimeWarning: invalid value encountered in cast
Code 2
No output
Code 3
No output