From 1c668c792603bbba4ae7cb61e8d1823346e4c43f Mon Sep 17 00:00:00 2001 From: Nicholas Junge Date: Thu, 7 Mar 2024 10:15:40 +0100 Subject: [PATCH] Add a lightning demo to the README.md Our package is so well-structured that this example is small, so it does not take lots of processing new information to understand. --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index 76afa44c..a594a513 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,40 @@ pip install nnbench poetry add nnbench ``` +## A ⚡️- quick demo + +To demonstrate how nnbench works, you can run the following in your Python interpreter: + +```python +# example.py +import nnbench + + +@nnbench.benchmark +def product(a: int, b: int) -> int: + return a * b + + +@nnbench.benchmark +def power(a: int, b: int) -> int: + return a ** b + + +runner = nnbench.BenchmarkRunner() +# run the above benchmarks with the parameters `a=2, b=10`... +record = runner.run("__main__", params={"a": 2, "b": 10}) +rep = nnbench.BenchmarkReporter() +rep.display(record) # ...and print the results to the terminal. + +# results in a table like the following: +# name function date value time_ns +# ------- ---------- ------------------- ------- --------- +# product product 2024-03-07T10:14:21 20 1000 +# power power 2024-03-07T10:14:21 1024 750 +``` + +For more advanced usages of the library, you can check out the [documentation](https://aai-institute.github.io/nnbench/latest/). + ## Contributing We encourage and welcome contributions from the community to enhance the project.