-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split benchmark for registry creation
- Loading branch information
Showing
1 changed file
with
17 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
import pytest | ||
|
||
import pint | ||
|
||
|
||
@pytest.mark.parametrize("args", [[(None,), tuple(), ("tiny",), ("", None)]]) | ||
def test_create_registry(benchmark, tiny_definition_file, args): | ||
if args[0] == "tiny": | ||
args = (tiny_definition_file, args[1:]) | ||
def test_create_empty_registry(benchmark): | ||
benchmark( | ||
pint.UnitRegistry, | ||
) | ||
|
||
|
||
def test_create_tiny_registry(benchmark, tiny_definition_file): | ||
benchmark(pint.UnitRegistry, tiny_definition_file) | ||
|
||
|
||
def test_create_default_registry(benchmark): | ||
benchmark( | ||
pint.UnitRegistry, | ||
) | ||
|
||
|
||
@benchmark | ||
def _(): | ||
if len(args) == 2: | ||
pint.UnitRegistry(args[0], cache_folder=args[1]) | ||
else: | ||
pint.UnitRegistry(*args) | ||
def test_create_default_registry_no_cache(benchmark): | ||
benchmark(pint.UnitRegistry, cache_folder=None) |