Skip to content

Commit f4805a3

Browse files
authored
Update benchmark (#26)
1 parent dc979a6 commit f4805a3

2 files changed

Lines changed: 27 additions & 24 deletions

File tree

README.md

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -93,32 +93,34 @@ This implementation does not include a clock sequence counter as defined in the
9393

9494
## Performance
9595

96+
Run the included shell script `./bench.sh` to test on your own machine.
97+
9698
MacBook Air
9799
```
98-
Python 3.9.7 (default, Oct 12 2021, 22:38:23)
99-
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
100-
Type "help", "copyright", "credits" or "license" for more information.
101-
>>> import timeit
102-
>>> timeit.timeit('uuid1()', number=100000, setup="from uuid import uuid1")
103-
0.14462158300011652
104-
>>> timeit.timeit('uuid6()', number=100000, setup="from uuid6 import uuid6")
105-
0.2687861250000019
106-
>>> timeit.timeit('uuid7()', number=100000, setup="from uuid6 import uuid7")
107-
0.22819437500000106
100+
Python 3.10.2
101+
Mean +- std dev: 1.02 us +- 0.01 us
102+
Mean +- std dev: 1.11 us +- 0.01 us
103+
Mean +- std dev: 2.34 us +- 0.02 us
104+
Mean +- std dev: 2.04 us +- 0.02 us
105+
+-----------+---------+-----------------------+-----------------------+-----------------------+
106+
| Benchmark | uuid1 | uuid4 | uuid6 | uuid7 |
107+
+===========+=========+=======================+=======================+=======================+
108+
| timeit | 1.02 us | 1.11 us: 1.08x slower | 2.34 us: 2.28x slower | 2.04 us: 1.99x slower |
109+
+-----------+---------+-----------------------+-----------------------+-----------------------+
108110
```
109111

110112
Google [Cloud Shell][cloud shell] VM
111113
```
112-
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
113-
[GCC 8.3.0] on linux
114-
Type "help", "copyright", "credits" or "license" for more information.
115-
>>> import timeit
116-
>>> timeit.timeit('uuid1()', number=100000, setup="from uuid import uuid1")
117-
1.2075679750000745
118-
>>> timeit.timeit('uuid6()', number=100000, setup="from uuid6 import uuid6")
119-
0.6328954440000416
120-
>>> timeit.timeit('uuid7()', number=100000, setup="from uuid6 import uuid7")
121-
0.4709622599998511
114+
Python 3.7.3
115+
Mean +- std dev: 10.1 us +- 0.7 us
116+
Mean +- std dev: 4.25 us +- 0.79 us
117+
Mean +- std dev: 9.37 us +- 1.75 us
118+
Mean +- std dev: 7.51 us +- 1.42 us
119+
+-----------+---------+-----------------------+-----------------------+-----------------------+
120+
| Benchmark | uuid1 | uuid4 | uuid6 | uuid7 |
121+
+===========+=========+=======================+=======================+=======================+
122+
| timeit | 10.1 us | 4.25 us: 2.38x faster | 9.37 us: 1.08x faster | 7.51 us: 1.35x faster |
123+
+-----------+---------+-----------------------+-----------------------+-----------------------+
122124
```
123125

124126
[ietf draft]: https://github.com/uuid6/uuid6-ietf-draft

bench.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/bin/bash
22
set -eu
33
TESTDIR=$(mktemp -d)
4-
python -m pyperf timeit -o "${TESTDIR}/uuid1.json" -s "import uuid" "uuid.uuid1()"
5-
python -m pyperf timeit -o "${TESTDIR}/uuid4.json" -s "import uuid" "uuid.uuid4()"
6-
python -m pyperf timeit -o "${TESTDIR}/uuid6.json" -s "import uuid6" "uuid6.uuid6()"
7-
python -m pyperf timeit -o "${TESTDIR}/uuid7.json" -s "import uuid6" "uuid6.uuid7()"
4+
python --version
5+
python -m pyperf timeit -q -o "${TESTDIR}/uuid1.json" -s "import uuid" "uuid.uuid1()"
6+
python -m pyperf timeit -q -o "${TESTDIR}/uuid4.json" -s "import uuid" "uuid.uuid4()"
7+
python -m pyperf timeit -q -o "${TESTDIR}/uuid6.json" -s "import uuid6" "uuid6.uuid6()"
8+
python -m pyperf timeit -q -o "${TESTDIR}/uuid7.json" -s "import uuid6" "uuid6.uuid7()"
89
python -m pyperf compare_to --table "${TESTDIR}/uuid1.json" "${TESTDIR}/uuid4.json" "${TESTDIR}/uuid6.json" "${TESTDIR}/uuid7.json"
910
rm -rf -- "${TESTDIR}"

0 commit comments

Comments
 (0)