Skip to content

Commit

Permalink
Reformat benchmarking files.
Browse files Browse the repository at this point in the history
  • Loading branch information
obi1kenobi committed Nov 26, 2024
1 parent aa97654 commit c644111
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
17 changes: 8 additions & 9 deletions python/bench/json_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ def create_json_with_large_array(length):
{
"index": i,
"data": f"This is element number {i}",
"nested": {
"id": i,
"value": f"Nested value for element {i}"
}
"nested": {"id": i, "value": f"Nested value for element {i}"},
}
for i in range(length)
]
Expand All @@ -27,8 +24,8 @@ def create_json_with_large_array(length):
"metadata": {
"created_at": "2024-10-22T19:00:00Z",
"author": "Python Program",
"version": 1.0
}
"version": 1.0,
},
}


Expand All @@ -44,12 +41,11 @@ def create_json_with_large_strings(length: int) -> dict:
"metadata": {
"created_at": "2024-10-22T19:00:00Z",
"author": "Python Program",
"version": 1.0
}
"version": 1.0,
},
}



def serialize_sequential(data):
"""Serialize data sequentially."""
return [orjson.dumps(json_obj) for json_obj in data]
Expand All @@ -72,6 +68,7 @@ def serialize_sequential_gz(data):
compressed_data.append(compressed)
return compressed_data


def serialize_parallel_gz(data):
"""Serialize data in parallel with zlib.
Expand All @@ -85,11 +82,13 @@ def compress_item(json_obj):
compressed_data = list(executor.map(compress_item, data))
return compressed_data


def gzip_parallel(serialized_data):
"""Compress serialized data in parallel using ThreadPoolExecutor and zlib."""
with ThreadPoolExecutor() as executor:
return list(executor.map(zlib.compress, serialized_data))


def gzip_sequential(serialized_data):
"""Compress serialized data sequentially using zlib."""
return [zlib.compress(serialized) for serialized in serialized_data]
Expand Down
1 change: 1 addition & 0 deletions python/bench/tracing_client_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def benchmark_run_creation(num_runs: int, json_size: int, samples: int = 1) -> D
json_size = 3_000
num_runs = 1000


def main(json_size: int, num_runs: int):
"""
Run benchmarks with different combinations of parameters and report results.
Expand Down

0 comments on commit c644111

Please sign in to comment.