Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions tests/test_local_sampling_benchmark.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import json
import pkgutil
from pkg_resources import resource_filename
from pathlib import Path

# Faster
def test_pkgutil_static_read(benchmark):
def get_sampling_rule():
# `.decode('utf-8')` needed for Python 3.4, 3.5
return json.loads(pkgutil.get_data(__name__, 'mock_sampling_rule.json').decode('utf-8'))
benchmark(get_sampling_rule)

# Slower
def test_pkg_resources_static_read(benchmark):
def test_pathlib_static_read(benchmark):
def get_sampling_rule():
with open(resource_filename(__name__, 'mock_sampling_rule.json')) as f:
with open(Path(__file__).parent / 'mock_sampling_rule.json') as f:
return json.load(f)
benchmark(get_sampling_rule)
Loading