Skip to main content

A simple suite for benchmarking

Project description

SimpleBench is a modern Python framework for benchmarking and performance testing of code.

As such it has the following goals:

  • Simple to use for simple benchmarks

  • Powerful enough to handle sophisticated benchmarking needs out-of-the-box

  • Flexible enough to handle complex custom benchmarking scenarios

  • Extensible to allow users to add their own functionality as needed

  • Full API and command-line interface support

Current Status

Alpha release 0.6.1-alpha.0

Functionally complete but not yet 100% tested or documented. There may be breaking changes before reaching version 1.0.

Additional report formats and benchmark options are planned.

Installing

Minimum Python Version: 3.10

From PyPI

  python -m pip install simplebench
  python -m pip install simplebench[graphs]
  python -m pip install simplebench[all]

From Source

git clone https://github.com/JerilynFranz/python-simplebench
cd python-simplebench
python3 -m pip install .[all]

Documentation

Basic Example

This is a basic example of creating and running a benchmark using SimpleBench. It demonstrates how to define a benchmark function, run it, and view an output report on the console. There are more detailed examples and tutorials in the documentation.

SimpleBench supports numerous benchmark options, report formats, command-line options, and customization points - this example focuses on the simplest case.

Defining a Benchmark

import simplebench

@simplebench.benchmark
def addition_benchmark():
    """A simple addition benchmark of Python's built-in sum function."""
   sum(range(1000))

if __name__ == "__main__":
    simplebench.main()

Running a Benchmark

  python my_benchmark_script.py --rich-table.ops --progress

Benchmark Output

This will run the addition_benchmark function and generate a rich table report of its performance.

                                                             addition_benchmark
                                                            operations per second

                                        A simple addition benchmark of Python's built-in sum function.
┏━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━┓
┃        ┃            ┃        ┃ Elapsed ┃    mean    ┃   median   ┃           ┃            ┃            ┃             ┃  std dev   ┃        ┃
┃   N    ┃ Iterations ┃ Rounds ┃ Seconds ┃   kOps/s   ┃   kOps/s   ┃ min Ops/s ┃ max kOps/s ┃ 5th kOps/s ┃ 95th kOps/s ┃   kOps/s   ┃  rsd%  ┃
┡━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━┩
│      1 │    46701   │      1 │  0.32   │    148.00  │    149.00  │   876.00  │    153.00  │    143.00  │    151.00   │      8.99  │  6.08% │
└────────┴────────────┴────────┴─────────┴────────────┴────────────┴───────────┴────────────┴────────────┴─────────────┴────────────┴────────┘

Authors and acknowledgments

  • Jerilyn Franz

Inspiration

“Simple things should be simple and complex things should be possible.” Alan Kay

“… with proper design, the features come cheaply. This approach is arduous, but continues to succeed.” Dennis Ritchie

License

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simplebench-0.6.1.tar.gz (274.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simplebench-0.6.1-py3-none-any.whl (246.4 kB view details)

Uploaded Python 3

File details

Details for the file simplebench-0.6.1.tar.gz.

File metadata

  • Download URL: simplebench-0.6.1.tar.gz
  • Upload date:
  • Size: 274.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for simplebench-0.6.1.tar.gz
Algorithm Hash digest
SHA256 c2c389af9496846203329416626e94d63018800c8fe02470725ef59166bae642
MD5 c1c84ce62b6630a61b3175dced662c15
BLAKE2b-256 a93cdd583868316ae98e1045968781219c51ebffe1029185d3356ca711037f93

See more details on using hashes here.

File details

Details for the file simplebench-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: simplebench-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 246.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for simplebench-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c2fc4b3093a4ff6067d14e9f4843d8a2c9bebd8307d7724db9605ba04ea4243a
MD5 58522fb176ac69132e1ff8f75d501be6
BLAKE2b-256 f8515aaa84575d6c2ca7b7eda7c599fdd98dda553c509567f6b7c770f861c718

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page