Skip to content

Commit d5349bb

Browse files
authored
Remove obsolete/unused code (#155)
* remove obsolete/unused code * remove more obsolete/unused code
1 parent d3f3e6a commit d5349bb

File tree

13 files changed

+17
-34
lines changed

13 files changed

+17
-34
lines changed

doc/conf.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
# All configuration values have a default; values that are commented out
1313
# serve to show the default.
1414

15-
import sys
16-
import os
17-
import shlex
18-
1915
# If extensions (or modules to document with autodoc) are in another directory,
2016
# add these directories to sys.path here. If the directory is relative to the
2117
# documentation root, use os.path.abspath to make it absolute, like shown here.

doc/examples/bench_time_func.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def bench_dict(loops, mydict):
66
range_it = range(loops)
77
t0 = pyperf.perf_counter()
88

9-
for loops in range_it:
9+
for _ in range_it:
1010
mydict['0']
1111
mydict['100']
1212
mydict['200']

pyperf/__main__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def group_by_name_ignored(self):
357357
yield (suite, ignored)
358358

359359

360-
def load_benchmarks(args, name=True):
360+
def load_benchmarks(args):
361361
data = Benchmarks()
362362
data.load_benchmark_suites(args.filenames)
363363
if getattr(args, 'benchmarks', None):
@@ -681,7 +681,6 @@ def cmd_convert(args):
681681
file=sys.stderr)
682682
sys.exit(1)
683683
except TypeError:
684-
raise
685684
print("ERROR: Metadata %r of benchmark %r is not an integer"
686685
% (name, benchmark.get_name()),
687686
file=sys.stderr)
@@ -699,7 +698,7 @@ def cmd_convert(args):
699698

700699

701700
def cmd_slowest(args):
702-
data = load_benchmarks(args, name=False)
701+
data = load_benchmarks(args)
703702
nslowest = args.n
704703

705704
use_title = (data.get_nsuite() > 1)

pyperf/_bench.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,7 @@ def _as_json(self, suite_metadata):
521521
metadata = self._get_common_metadata()
522522
common_metadata = dict(metadata, **suite_metadata)
523523

524-
data = {}
525-
data['runs'] = [run._as_json(common_metadata) for run in self._runs]
524+
data = {'runs': [run._as_json(common_metadata) for run in self._runs]}
526525
metadata = _exclude_common_metadata(metadata, suite_metadata)
527526
if metadata:
528527
data['metadata'] = metadata

pyperf/_cli.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ def format_run(bench, run_index, run, common_metadata=None, raw=False,
8787
loops, value = warmup
8888
raw_value = value * (loops * inner_loops)
8989
if raw:
90-
text = format_value(raw_value)
9190
text = ("%s (loops: %s)"
9291
% (format_value(raw_value),
9392
format_number(loops)))
@@ -273,8 +272,7 @@ def format_stats(bench, lines):
273272
lines.append('')
274273

275274
# Minimum
276-
table = []
277-
table.append(("Minimum", bench.format_value(min(values))))
275+
table = [("Minimum", bench.format_value(min(values)))]
278276

279277
# Median +- MAD
280278
median = bench.median()
@@ -382,8 +380,6 @@ def value_bucket(value):
382380

383381
value_width = max([len(bench.format_value(bucket * value_k))
384382
for bucket in range(bucket_min, bucket_max + 1)])
385-
width = columns - value_width
386-
387383
line = ': %s #' % count_max
388384
width = columns - (value_width + len(line))
389385
if not extend:
@@ -517,7 +513,7 @@ def format_result_value(bench):
517513
return _format_result_value(bench)
518514

519515

520-
def format_result(bench, prefix=True):
516+
def format_result(bench):
521517
loops = None
522518
warmups = None
523519
for run in bench._runs:

pyperf/_collect_metadata.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ def collect_cpu_freq(metadata, cpus):
233233
# Example: "processor 0: version = 00, identification = [...]"
234234
match = re.match(r'^processor ([0-9]+): ', line)
235235
if match is None:
236-
raise Exception
237236
# unknown /proc/cpuinfo format: silently ignore and exit
238237
return
239238

@@ -410,9 +409,7 @@ def collect_cpu_metadata(metadata):
410409

411410

412411
def collect_metadata(process=True):
413-
metadata = {}
414-
metadata['perf_version'] = pyperf.__version__
415-
metadata['date'] = format_datetime(datetime.datetime.now())
412+
metadata = {'perf_version': pyperf.__version__, 'date': format_datetime(datetime.datetime.now())}
416413

417414
collect_system_metadata(metadata)
418415
collect_cpu_metadata(metadata)

pyperf/_compare.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,7 @@ def sort_key(results):
284284
for item in self.all_results[0]:
285285
headers.append(item.changed.name)
286286

287-
all_norm_means = []
288-
for column in headers[2:]:
289-
all_norm_means.append([])
287+
all_norm_means = [[] for _ in range(len(headers[2:]))]
290288

291289
rows = []
292290
not_significant = []

pyperf/_process_time.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def bench_process(loops, args, kw, profile_filename=None):
6060
temp_profile_filename = tempfile.mktemp()
6161
args = [args[0], "-m", "cProfile", "-o", temp_profile_filename] + args[1:]
6262

63-
for loop in range_it:
63+
for _ in range_it:
6464
start_rss = get_max_rss()
6565

6666
proc = subprocess.Popen(args, **kw)
@@ -75,8 +75,6 @@ def bench_process(loops, args, kw, profile_filename=None):
7575
os.unlink(temp_profile_filename)
7676
sys.exit(exitcode)
7777

78-
proc = None
79-
8078
rss = get_max_rss() - start_rss
8179
max_rss = max(max_rss, rss)
8280

pyperf/_runner.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class Runner:
7171

7272
# Default parameters are chosen to have approximatively a run of 0.5 second
7373
# and so a total duration of 5 seconds by default
74-
def __init__(self, values=None, warmups=None, processes=None,
74+
def __init__(self, values=None, processes=None,
7575
loops=0, min_time=0.1, metadata=None,
7676
show_name=True,
7777
program_args=None, add_cmdline_args=None,
@@ -485,7 +485,7 @@ def bench_time_func(self, name, time_func, *args, **kwargs):
485485
if self.args.profile:
486486
profiler, time_func = profiling_wrapper(time_func)
487487

488-
def task_func(task, loops):
488+
def task_func(_, loops):
489489
return time_func(loops, *args)
490490

491491
task = WorkerProcessTask(self, name, task_func, metadata)
@@ -514,7 +514,7 @@ def bench_func(self, name, func, *args, **kwargs):
514514
if self.args.profile:
515515
profiler, func = profiling_wrapper(func)
516516

517-
def task_func(task, loops):
517+
def task_func(_, loops):
518518
# use fast local variables
519519
local_timer = time.perf_counter
520520
local_func = func
@@ -557,7 +557,7 @@ def bench_async_func(self, name, func, *args, **kwargs):
557557
if self.args.profile:
558558
profiler, func = profiling_wrapper(func)
559559

560-
def task_func(task, loops):
560+
def task_func(_, loops):
561561
if loops != 1:
562562
async def main():
563563
# use fast local variables

pyperf/_system.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def write_msr(self, cpu, reg_num, value):
213213
fd = os.open(path, os.O_WRONLY)
214214
try:
215215
if hasattr(os, 'pwrite'):
216-
data = os.pwrite(fd, data, reg_num)
216+
os.pwrite(fd, data, reg_num)
217217
else:
218218
os.lseek(fd, reg_num, os.SEEK_SET)
219219
os.write(fd, data)

0 commit comments

Comments
 (0)