Skip to content

Commit

Permalink
Merge pull request #27 from sontek/add_benchmark_for_precise
Browse files Browse the repository at this point in the history
This adds a benchmark for precise vs not precise
  • Loading branch information
kenrobbins committed Sep 18, 2015
2 parents cd95027 + 59e7909 commit cc22b01
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,38 @@ def test_json_medium_complex_objects(name, serialize, deserialize):
)

print(msg)


@pytest.mark.benchmark
def test_double_performance_float_precision():
from functools import partial

print("\nArray with 256 doubles:")
name = 'rapidjson (precise)'
serialize = rapidjson.dumps
deserialize = rapidjson.loads

ser_data, des_data = run_client_test(
name, serialize, deserialize,
data=doubles,
iterations=50000,
)
msg = "%-11s serialize: %0.3f deserialize: %0.3f total: %0.3f" % (
name, ser_data, des_data, ser_data + des_data
)

print(msg)

name = 'rapidjson (not precise)'
serialize = rapidjson.dumps
deserialize = partial(rapidjson.loads, precise_float=False)

ser_data, des_data = run_client_test(
name, serialize, deserialize,
data=doubles,
iterations=50000,
)
msg = "%-11s serialize: %0.3f deserialize: %0.3f total: %0.3f" % (
name, ser_data, des_data, ser_data + des_data
)
print(msg)

0 comments on commit cc22b01

Please sign in to comment.