From a17b506fcac02c9f73b2bd6e8054f71ff74c917a Mon Sep 17 00:00:00 2001 From: Oittaa Date: Sun, 6 Feb 2022 02:53:23 +0100 Subject: [PATCH] Update benchmark --- README.md | 42 ++++++++++++++++++++++-------------------- bench.sh | 9 +++++---- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 517d058..dae14e2 100644 --- a/README.md +++ b/README.md @@ -93,32 +93,34 @@ This implementation does not include a clock sequence counter as defined in the ## Performance +Run the included shell script `./bench.sh` to test on your own machine. + MacBook Air ``` -Python 3.9.7 (default, Oct 12 2021, 22:38:23) -[Clang 13.0.0 (clang-1300.0.29.3)] on darwin -Type "help", "copyright", "credits" or "license" for more information. ->>> import timeit ->>> timeit.timeit('uuid1()', number=100000, setup="from uuid import uuid1") -0.14462158300011652 ->>> timeit.timeit('uuid6()', number=100000, setup="from uuid6 import uuid6") -0.2687861250000019 ->>> timeit.timeit('uuid7()', number=100000, setup="from uuid6 import uuid7") -0.22819437500000106 +Python 3.10.2 +Mean +- std dev: 1.02 us +- 0.01 us +Mean +- std dev: 1.11 us +- 0.01 us +Mean +- std dev: 2.34 us +- 0.02 us +Mean +- std dev: 2.04 us +- 0.02 us ++-----------+---------+-----------------------+-----------------------+-----------------------+ +| Benchmark | uuid1 | uuid4 | uuid6 | uuid7 | ++===========+=========+=======================+=======================+=======================+ +| timeit | 1.02 us | 1.11 us: 1.08x slower | 2.34 us: 2.28x slower | 2.04 us: 1.99x slower | ++-----------+---------+-----------------------+-----------------------+-----------------------+ ``` Google [Cloud Shell][cloud shell] VM ``` -Python 3.7.3 (default, Jan 22 2021, 20:04:44) -[GCC 8.3.0] on linux -Type "help", "copyright", "credits" or "license" for more information. ->>> import timeit ->>> timeit.timeit('uuid1()', number=100000, setup="from uuid import uuid1") -1.2075679750000745 ->>> timeit.timeit('uuid6()', number=100000, setup="from uuid6 import uuid6") -0.6328954440000416 ->>> timeit.timeit('uuid7()', number=100000, setup="from uuid6 import uuid7") -0.4709622599998511 +Python 3.7.3 +Mean +- std dev: 10.1 us +- 0.7 us +Mean +- std dev: 4.25 us +- 0.79 us +Mean +- std dev: 9.37 us +- 1.75 us +Mean +- std dev: 7.51 us +- 1.42 us ++-----------+---------+-----------------------+-----------------------+-----------------------+ +| Benchmark | uuid1 | uuid4 | uuid6 | uuid7 | ++===========+=========+=======================+=======================+=======================+ +| timeit | 10.1 us | 4.25 us: 2.38x faster | 9.37 us: 1.08x faster | 7.51 us: 1.35x faster | ++-----------+---------+-----------------------+-----------------------+-----------------------+ ``` [ietf draft]: https://github.com/uuid6/uuid6-ietf-draft diff --git a/bench.sh b/bench.sh index 4177933..13ea6f3 100755 --- a/bench.sh +++ b/bench.sh @@ -1,9 +1,10 @@ #!/bin/bash set -eu TESTDIR=$(mktemp -d) -python -m pyperf timeit -o "${TESTDIR}/uuid1.json" -s "import uuid" "uuid.uuid1()" -python -m pyperf timeit -o "${TESTDIR}/uuid4.json" -s "import uuid" "uuid.uuid4()" -python -m pyperf timeit -o "${TESTDIR}/uuid6.json" -s "import uuid6" "uuid6.uuid6()" -python -m pyperf timeit -o "${TESTDIR}/uuid7.json" -s "import uuid6" "uuid6.uuid7()" +python --version +python -m pyperf timeit -q -o "${TESTDIR}/uuid1.json" -s "import uuid" "uuid.uuid1()" +python -m pyperf timeit -q -o "${TESTDIR}/uuid4.json" -s "import uuid" "uuid.uuid4()" +python -m pyperf timeit -q -o "${TESTDIR}/uuid6.json" -s "import uuid6" "uuid6.uuid6()" +python -m pyperf timeit -q -o "${TESTDIR}/uuid7.json" -s "import uuid6" "uuid6.uuid7()" python -m pyperf compare_to --table "${TESTDIR}/uuid1.json" "${TESTDIR}/uuid4.json" "${TESTDIR}/uuid6.json" "${TESTDIR}/uuid7.json" rm -rf -- "${TESTDIR}"