Skip to content

Commit

Permalink
Update benchmarks (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
aminalaee authored Mar 31, 2023
1 parent 754f6dd commit 0a905e8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e')
| Benchmark | Min | Max | Mean | Min (+) | Max (+) | Mean (+) |
|-----------------|---------|---------|---------|-----------------|-----------------|-----------------|
| UUID V1 | 0.058 | 0.059 | 0.058 | 0.005 (12.0x) | 0.005 (11.9x) | 0.005 (12.0x) |
| UUID V3 | 0.063 | 0.064 | 0.063 | 0.008 (7.9x) | 0.008 (8.1x) | 0.008 (8.0x) |
| UUID V4 | 0.041 | 0.041 | 0.041 | 0.004 (11.1x) | 0.004 (10.8x) | 0.004 (10.9x) |
| UUID V5 | 0.064 | 0.066 | 0.065 | 0.008 (8.1x) | 0.008 (8.1x) | 0.008 (8.1x) |
| UUID from hex | 0.024 | 0.025 | 0.024 | 0.004 (6.7x) | 0.004 (6.6x) | 0.004 (6.6x) |
| UUID from bytes | 0.024 | 0.025 | 0.024 | 0.004 (6.7x) | 0.004 (6.6x) | 0.004 (6.7x) |
| UUID from int | 0.024 | 0.025 | 0.024 | 0.004 (6.6x) | 0.004 (6.7x) | 0.004 (6.6x) |
| UUID from fields | 0.028 | 0.028 | 0.028 | 0.009 (3.1x) | 0.009 (3.1x) | 0.009 (3.1x) |

## Limitations

Expand Down
11 changes: 11 additions & 0 deletions benchmarks/bench_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ def uuid_utils_uuid1() -> None:
uuid_utils.uuid1(node)


def uuid_uuid3() -> None:
for _ in range(10_000):
uuid.uuid3(namespace=uuid.NAMESPACE_DNS, name="python.org")


def uuid_utils_uuid3() -> None:
for _ in range(10_000):
uuid_utils.uuid3(namespace=uuid_utils.NAMESPACE_DNS, name="python.org")


def uuid_uuid4() -> None:
for _ in range(10_000):
uuid.uuid4()
Expand All @@ -37,6 +47,7 @@ def uuid_utils_uuid5() -> None:

__benchmarks__ = [
(uuid_uuid1, uuid_utils_uuid1, "UUID V1"),
(uuid_uuid3, uuid_utils_uuid3, "UUID V3"),
(uuid_uuid4, uuid_utils_uuid4, "UUID V4"),
(uuid_uuid5, uuid_utils_uuid5, "UUID V5"),
]
11 changes: 11 additions & 0 deletions benchmarks/bench_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,19 @@ def uuid_utils_from_int() -> None:
uuid_utils.UUID("a8098c1a-f86e-11da-bd1a-00112444be1e")


def uuid_from_fields() -> None:
for _ in range(10_000):
uuid.UUID(fields=(2819197978, 63598, 4570, 189, 26, 73622928926))


def uuid_utils_from_fields() -> None:
for _ in range(10_000):
uuid_utils.UUID(fields=(2819197978, 63598, 4570, 189, 26, 73622928926))


__benchmarks__ = [
(uuid_from_hex, uuid_utils_from_hex, "UUID from hex"),
(uuid_from_bytes, uuid_utils_from_bytes, "UUID from bytes"),
(uuid_from_int, uuid_utils_from_int, "UUID from int"),
(uuid_from_fields, uuid_utils_from_fields, "UUID from fields"),
]

0 comments on commit 0a905e8

Please sign in to comment.