mirror of
https://github.com/apache/arrow.git
synced 2026-10-29 00:56:31 +08:00
Improve archery benchmark support
- Add '\n' do diff json output adhering to jsonlines - Add support for items_per_second metrics - Add `--pdb` option to drop a pdb shell on uncaught exception
This commit is contained in:
1 parent
bea76ed0ee
commit
a7b4f5f50d
2 files changed
+23
-8
No files matched your search
@@ -87,13 +87,14 @@ class GoogleBenchmarkObservation:
|
||||
"""
|
||||
|
||||
def __init__(self, name, real_time, cpu_time, time_unit, size=None,
|
||||
bytes_per_second=None, **kwargs):
|
||||
bytes_per_second=None, items_per_second=None, **kwargs):
|
||||
self._name = name
|
||||
self.real_time = real_time
|
||||
self.cpu_time = cpu_time
|
||||
self.time_unit = time_unit
|
||||
self.size = size
|
||||
self.bytes_per_second = bytes_per_second
|
||||
self.items_per_second = items_per_second
|
||||
|
||||
@property
|
||||
def is_agg(self):
|
||||
@@ -118,11 +119,21 @@ class GoogleBenchmarkObservation:
|
||||
@property
|
||||
def value(self):
|
||||
""" Return the benchmark value."""
|
||||
return self.bytes_per_second if self.size else self.time
|
||||
if self.bytes_per_second:
|
||||
return self.bytes_per_second
|
||||
elif self.items_per_second:
|
||||
return self.items_per_second
|
||||
else:
|
||||
return self.time
|
||||
|
||||
@property
|
||||
def unit(self):
|
||||
return "bytes_per_second" if self.size else self.time_unit
|
||||
if self.bytes_per_second:
|
||||
return "bytes_per_second"
|
||||
elif self.items_per_second:
|
||||
return "items_per_second"
|
||||
else:
|
||||
return self.time_unit
|
||||
|
||||
def __repr__(self):
|
||||
return f"{self.value}"
|
||||
@@ -147,9 +158,7 @@ class GoogleBenchmark(Benchmark):
|
||||
_, runs = partition(lambda b: b.is_agg, runs)
|
||||
self.runs = sorted(runs, key=lambda b: b.value)
|
||||
unit = self.runs[0].unit
|
||||
# If `size` is found in the json dict, then the benchmark is reported
|
||||
# in bytes per second
|
||||
less_is_better = self.runs[0].size is None
|
||||
less_is_better = not unit.endswith("per_second")
|
||||
values = [b.value for b in self.runs]
|
||||
super().__init__(name, unit, less_is_better, values)
|
||||
|
||||
|
||||
@@ -37,10 +37,12 @@ logging.basicConfig(level=logging.INFO)
|
||||
@click.group()
|
||||
@click.option("--debug", type=bool, is_flag=True, default=False,
|
||||
help="Increase logging with debugging output.")
|
||||
@click.option("--pdb", type=bool, is_flag=True, default=False,
|
||||
help="Invoke pdb on uncaught exception.")
|
||||
@click.option("-q", "--quiet", type=bool, is_flag=True, default=False,
|
||||
help="Silence executed commands.")
|
||||
@click.pass_context
|
||||
def archery(ctx, debug, quiet):
|
||||
def archery(ctx, debug, pdb, quiet):
|
||||
""" Apache Arrow developer utilities.
|
||||
|
||||
See sub-commands help with `archery <cmd> --help`.
|
||||
@@ -53,6 +55,10 @@ def archery(ctx, debug, quiet):
|
||||
if debug:
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
if pdb:
|
||||
import pdb
|
||||
sys.excepthook = lambda t, v, e: pdb.pm()
|
||||
|
||||
|
||||
def validate_arrow_sources(ctx, param, src):
|
||||
""" Ensure a directory contains Arrow cpp sources. """
|
||||
@@ -357,7 +363,7 @@ def benchmark_diff(ctx, src, preserve, suite_filter, benchmark_filter,
|
||||
for comparator in runner_comp.comparisons:
|
||||
regressions += comparator.regression
|
||||
json.dump(comparator, output, cls=JsonEncoder)
|
||||
output.write('\n')
|
||||
output.write("\n")
|
||||
|
||||
sys.exit(regressions)
|
||||
|
||||
|
||||
Reference in new issue
Block a user