Skip to content

Commit 385f603

Browse files
carsonipjeffwidman
authored andcommitted
Fix benchmarks to use pyperf
1 parent d54aaf6 commit 385f603

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

benchmarks/README

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
The `record_batch_*` benchmarks in this section are written using
2-
``perf`` library, created by Viktor Stinner. For more information on how to get
3-
reliable results of test runs please consult
4-
https://perf.readthedocs.io/en/latest/run_benchmark.html.
2+
``pyperf`` library, created by Victor Stinner. For more information on
3+
how to get reliable results of test runs please consult
4+
https://pyperf.readthedocs.io/en/latest/run_benchmark.html.

benchmarks/record_batch_compose.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
import random
77

8-
import perf
8+
import pyperf
99

1010
from kafka.record.memory_records import MemoryRecordsBuilder
1111

@@ -52,7 +52,7 @@ def func(loops, magic):
5252
results = []
5353

5454
# Main benchmark code.
55-
t0 = perf.perf_counter()
55+
t0 = pyperf.perf_counter()
5656
for _ in range(loops):
5757
batch = MemoryRecordsBuilder(
5858
magic, batch_size=DEFAULT_BATCH_SIZE, compression_type=0)
@@ -64,14 +64,14 @@ def func(loops, magic):
6464
batch.close()
6565
results.append(batch.buffer())
6666

67-
res = perf.perf_counter() - t0
67+
res = pyperf.perf_counter() - t0
6868

6969
finalize(results)
7070

7171
return res
7272

7373

74-
runner = perf.Runner()
74+
runner = pyperf.Runner()
7575
runner.bench_time_func('batch_append_v0', func, 0)
7676
runner.bench_time_func('batch_append_v1', func, 1)
7777
runner.bench_time_func('batch_append_v2', func, 2)

benchmarks/record_batch_read.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
import random
77

8-
import perf
8+
import pyperf
99

1010
from kafka.record.memory_records import MemoryRecords, MemoryRecordsBuilder
1111

@@ -61,7 +61,7 @@ def func(loops, magic):
6161

6262
# Main benchmark code.
6363
batch_data = next(precomputed_samples)
64-
t0 = perf.perf_counter()
64+
t0 = pyperf.perf_counter()
6565
for _ in range(loops):
6666
records = MemoryRecords(batch_data)
6767
while records.has_next():
@@ -70,13 +70,13 @@ def func(loops, magic):
7070
for record in batch:
7171
results.append(record.value)
7272

73-
res = perf.perf_counter() - t0
73+
res = pyperf.perf_counter() - t0
7474
finalize(results)
7575

7676
return res
7777

7878

79-
runner = perf.Runner()
79+
runner = pyperf.Runner()
8080
runner.bench_time_func('batch_read_v0', func, 0)
8181
runner.bench_time_func('batch_read_v1', func, 1)
8282
runner.bench_time_func('batch_read_v2', func, 2)

benchmarks/varint_speed.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22
from __future__ import print_function
3-
import perf
3+
import pyperf
44
from kafka.vendor import six
55

66

@@ -398,7 +398,7 @@ def decode_varint_3(buffer, pos=0):
398398
# import dis
399399
# dis.dis(decode_varint_3)
400400

401-
runner = perf.Runner()
401+
runner = pyperf.Runner()
402402
# Encode algorithms returning a bytes result
403403
for bench_func in [
404404
encode_varint_1,

0 commit comments

Comments
 (0)