projects
/
python_utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
142ec2f
)
Code cleanup.
author
Scott
<
[email protected]
>
Tue, 18 Jan 2022 04:40:49 +0000
(20:40 -0800)
committer
Scott
<
[email protected]
>
Tue, 18 Jan 2022 04:40:49 +0000
(20:40 -0800)
unittest_utils.py
patch
|
blob
|
history
diff --git
a/unittest_utils.py
b/unittest_utils.py
index 5f4528348a0a3abb2538355db13884f21ca12fcd..d63f2b566b51b33bc794340b0d425d29a7e89142 100644
(file)
--- a/
unittest_utils.py
+++ b/
unittest_utils.py
@@
-218,19
+218,21
@@
def check_method_for_perf_regressions(func: Callable) -> Callable:
not config.config['unittests_ignore_perf']
):
msg = f'''{func_id} performance has regressed unacceptably.
not config.config['unittests_ignore_perf']
):
msg = f'''{func_id} performance has regressed unacceptably.
-{
hist[-1]:f}s is the slowest record in {len(hist)} db
perf samples.
-It just ran in {run_time:f}s which is
>5 stdevs slower than the slowest sample
.
+{
slowest:f}s is the slowest runtime on record in {len(hist)}
perf samples.
+It just ran in {run_time:f}s which is
4+ stdevs slower than the slowest
.
Here is the current, full db perf timing distribution:
'''
for x in hist:
msg += f'{x:f}\n'
logger.error(msg)
Here is the current, full db perf timing distribution:
'''
for x in hist:
msg += f'{x:f}\n'
logger.error(msg)
- slf = args[0]
- slf.fail(msg)
+ slf = args[0]
# Peek at the wrapped function's self ref.
+ slf.fail(msg)
# ...to fail the testcase.
else:
hist.append(run_time)
else:
hist.append(run_time)
+ # Don't spam the database with samples; just pick a random
+ # sample from what we have and store that back.
n = min(config.config['unittests_num_perf_samples'], len(hist))
hist = random.sample(hist, n)
hist.sort()
n = min(config.config['unittests_num_perf_samples'], len(hist))
hist = random.sample(hist, n)
hist.sort()
@@
-241,6
+243,18
@@
Here is the current, full db perf timing distribution:
def check_all_methods_for_perf_regressions(prefix='test_'):
def check_all_methods_for_perf_regressions(prefix='test_'):
+ """Decorate unittests with this to pay attention to the perf of the
+ testcode and flag perf regressions. e.g.
+
+ import unittest_utils as uu
+
+ @uu.check_all_methods_for_perf_regressions()
+ class TestMyClass(unittest.TestCase):
+
+ def test_some_part_of_my_class(self):
+ ...
+
+ """
def decorate_the_testcase(cls):
if issubclass(cls, unittest.TestCase):
for name, m in inspect.getmembers(cls, inspect.isfunction):
def decorate_the_testcase(cls):
if issubclass(cls, unittest.TestCase):
for name, m in inspect.getmembers(cls, inspect.isfunction):