diff --git a/benches/README.md b/benches/README.md index f6e5129617..b20079ba25 100644 --- a/benches/README.md +++ b/benches/README.md @@ -7,7 +7,14 @@ These are some files to determine performance of rustpython. Running `cargo bench` from the root of the repository will start the benchmarks. Once done there will be a graphical report under `target/criterion/report/index.html` that you can use use to view the results. -To view Python tracebacks during benchmarks, run `RUST_BACKTRACE=1 cargo bench`. You can also bench against a +`cargo bench` supports name matching to run a subset of the benchmarks. To +run only the sort microbenchmark, you can run: + +```shell +cargo bench sort +``` + +To view Python tracebacks during benchmarks, run `RUST_BACKTRACE=1 cargo bench`. You can also bench against a specific installed Python version by running: ```shell diff --git a/benches/microbenchmarks/sort.py b/benches/microbenchmarks/sort.py new file mode 100644 index 0000000000..f6f8ee03a4 --- /dev/null +++ b/benches/microbenchmarks/sort.py @@ -0,0 +1,8 @@ +from random import random, seed +seed(0) + +unsorted_list = [random() for _ in range(5 * ITERATIONS)] + +# --- + +unsorted_list.sort()