Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix benchmarks to use pyperf #1986

Merged
merged 1 commit into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions benchmarks/README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The `record_batch_*` benchmarks in this section are written using
``perf`` library, created by Viktor Stinner. For more information on how to get
reliable results of test runs please consult
https://perf.readthedocs.io/en/latest/run_benchmark.html.
``pyperf`` library, created by Victor Stinner. For more information on
how to get reliable results of test runs please consult
https://pyperf.readthedocs.io/en/latest/run_benchmark.html.
8 changes: 4 additions & 4 deletions benchmarks/record_batch_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
import random

import perf
import pyperf

from kafka.record.memory_records import MemoryRecordsBuilder

Expand Down Expand Up @@ -52,7 +52,7 @@ def func(loops, magic):
results = []

# Main benchmark code.
t0 = perf.perf_counter()
t0 = pyperf.perf_counter()
for _ in range(loops):
batch = MemoryRecordsBuilder(
magic, batch_size=DEFAULT_BATCH_SIZE, compression_type=0)
Expand All @@ -64,14 +64,14 @@ def func(loops, magic):
batch.close()
results.append(batch.buffer())

res = perf.perf_counter() - t0
res = pyperf.perf_counter() - t0

finalize(results)

return res


runner = perf.Runner()
runner = pyperf.Runner()
runner.bench_time_func('batch_append_v0', func, 0)
runner.bench_time_func('batch_append_v1', func, 1)
runner.bench_time_func('batch_append_v2', func, 2)
8 changes: 4 additions & 4 deletions benchmarks/record_batch_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
import random

import perf
import pyperf

from kafka.record.memory_records import MemoryRecords, MemoryRecordsBuilder

Expand Down Expand Up @@ -61,7 +61,7 @@ def func(loops, magic):

# Main benchmark code.
batch_data = next(precomputed_samples)
t0 = perf.perf_counter()
t0 = pyperf.perf_counter()
for _ in range(loops):
records = MemoryRecords(batch_data)
while records.has_next():
Expand All @@ -70,13 +70,13 @@ def func(loops, magic):
for record in batch:
results.append(record.value)

res = perf.perf_counter() - t0
res = pyperf.perf_counter() - t0
finalize(results)

return res


runner = perf.Runner()
runner = pyperf.Runner()
runner.bench_time_func('batch_read_v0', func, 0)
runner.bench_time_func('batch_read_v1', func, 1)
runner.bench_time_func('batch_read_v2', func, 2)
4 changes: 2 additions & 2 deletions benchmarks/varint_speed.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
from __future__ import print_function
import perf
import pyperf
from kafka.vendor import six


Expand Down Expand Up @@ -398,7 +398,7 @@ def decode_varint_3(buffer, pos=0):
# import dis
# dis.dis(decode_varint_3)

runner = perf.Runner()
runner = pyperf.Runner()
# Encode algorithms returning a bytes result
for bench_func in [
encode_varint_1,
Expand Down