diff options
author | Hugo van Kemenade <hugovk@users.noreply.github.com> | 2021-05-03 01:40:05 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-02 15:40:05 -0700 |
commit | df79a6390f6d0531f6411f745d0ccd2c3d674883 (patch) | |
tree | 182575a9f279d791c9a3f724ed8373c750cb49bd /perf/perf_measure.py | |
parent | bb73791b59f74b6621a87036c14a6be6a23e0e55 (diff) | |
download | python-coveragepy-git-df79a6390f6d0531f6411f745d0ccd2c3d674883.tar.gz |
refactor: remove redundant Python 2 code (#1155)
* Remove Python 2 code
* Upgrade Python syntax with pyupgrade
* Upgrade Python syntax with pyupgrade --py3-plus
* Upgrade Python syntax with pyupgrade --py36-plus
* Remove unused imports
Diffstat (limited to 'perf/perf_measure.py')
-rw-r--r-- | perf/perf_measure.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/perf/perf_measure.py b/perf/perf_measure.py index 652f0fa8..e8f9ea98 100644 --- a/perf/perf_measure.py +++ b/perf/perf_measure.py @@ -38,15 +38,15 @@ def child(line_count): def mk_main(file_count, call_count, line_count): lines = [] lines.extend( - "import test{}".format(idx) for idx in range(file_count) + f"import test{idx}" for idx in range(file_count) ) lines.extend( - "test{}.parent({}, {})".format(idx, call_count, line_count) for idx in range(file_count) + f"test{idx}.parent({call_count}, {line_count})" for idx in range(file_count) ) return "\n".join(lines) -class StressTest(object): +class StressTest: def __init__(self): self.module_cleaner = SuperModuleCleaner() @@ -55,7 +55,7 @@ class StressTest(object): self.module_cleaner.clean_local_file_imports() for idx in range(file_count): - make_file('test{}.py'.format(idx), TEST_FILE) + make_file(f'test{idx}.py', TEST_FILE) make_file('testmain.py', mk_main(file_count, call_count, line_count)) # Run it once just to get the disk caches loaded up. @@ -137,7 +137,7 @@ class StressTest(object): yield kwargs['file_count'] * kwargs['call_count'] * kwargs['line_count'] ops = sum(sum(operations(thing)) for thing in ["file", "call", "line"]) - print("{:.1f}M operations".format(ops/1e6)) + print(f"{ops/1e6:.1f}M operations") def check_coefficients(self): # For checking the calculation of actual stats: @@ -161,14 +161,14 @@ class StressTest(object): } kwargs[thing+"_count"] = n res = self._compute_overhead(**kwargs) - per_thing.append(res.overhead / getattr(res, "{}s".format(thing))) + per_thing.append(res.overhead / getattr(res, f"{thing}s")) pct_thing.append(res.covered / res.baseline * 100) - out = "Per {}: ".format(thing) + out = f"Per {thing}: " out += "mean = {:9.3f}us, stddev = {:8.3f}us, ".format( statistics.mean(per_thing)*1e6, statistics.stdev(per_thing)*1e6 ) - out += "min = {:9.3f}us, ".format(min(per_thing)*1e6) + out += f"min = {min(per_thing)*1e6:9.3f}us, " out += "pct = {:6.1f}%, stddev = {:6.1f}%".format( statistics.mean(pct_thing), statistics.stdev(pct_thing) ) @@ -181,7 +181,7 @@ class StressTest(object): if __name__ == '__main__': with tempfile.TemporaryDirectory(prefix="coverage_stress_") as tempdir: - print("Working in {}".format(tempdir)) + print(f"Working in {tempdir}") os.chdir(tempdir) sys.path.insert(0, ".") |