Skip to content

Commit 8ad460e

Browse files
committed
Add benchmarks for json read
1 parent 7745952 commit 8ad460e

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

tests/mock_sampling_rule.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"version": 2,
3+
"default": {
4+
"fixed_target": 1,
5+
"rate": 0.05
6+
},
7+
"rules": [
8+
]
9+
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import json
2+
import pkgutil
3+
from pkg_resources import resource_filename
4+
5+
from aws_xray_sdk.core.sampling.local.sampler import LocalSampler
6+
7+
def test_pkg_resources_static_read(benchmark):
8+
def get_sampling_rule():
9+
with open(resource_filename(__name__, 'mock_sampling_rule.json')) as f:
10+
return json.load(f)
11+
benchmark(get_sampling_rule)
12+
13+
def test_pkgutil_static_read(benchmark):
14+
def get_sampling_rule():
15+
json.loads(pkgutil.get_data(__name__, 'mock_sampling_rule.json'))
16+
benchmark(get_sampling_rule)

tox.ini

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ skip_missing_interpreters = True
1616
passenv = TOXENV CI TRAVIS TRAVIS_* CODECOV_*
1717
deps =
1818
pytest > 3.0.0
19+
pytest-benchmark
1920
coverage==4.5.4
2021
codecov
2122
requests

0 commit comments

Comments
 (0)