MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / run_case

Method run_case

test/perf/compiled_extensions/base.py:73–119  ·  view source on GitHub ↗
(cls, factor, filter_)

Source from the content-addressed store, hash-verified

71
72 @classmethod
73 def run_case(cls, factor, filter_):
74 objects = cls.import_impl()
75 cls.init_class()
76 number = max(1, int(cls.NUMBER * factor))
77
78 stack = [c for c in cls.mro() if c not in {object, Case}]
79 methods = []
80 while stack:
81 curr = stack.pop(0)
82 # dict keeps the definition order, dir is instead sorted
83 methods += [
84 m
85 for m, fn in curr.__dict__.items()
86 if hasattr(fn, "__test_case__")
87 ]
88
89 if filter_:
90 methods = [m for m in methods if re.search(filter_, m)]
91
92 results = defaultdict(dict)
93 for name, impl in objects:
94 print(f"Running {name:<10} ", end="", flush=True)
95 impl_case = cls(impl)
96 fails = []
97 for m in methods:
98 call = getattr(impl_case, m)
99 try:
100 t_num = number
101 fn_num = getattr(call, "__number__", None)
102 if fn_num is not None:
103 t_num = max(1, int(fn_num * factor))
104 value = timeit(call, number=t_num)
105 print(".", end="", flush=True)
106 except Exception as e:
107 fails.append(f"{name}::{m} error: {e!r}")
108 print("x", end="", flush=True)
109 value = float("nan")
110
111 results[name][m] = value
112 print(" Done")
113 for f in fails:
114 print("\t", f)
115
116 before = set(results)
117 cls.update_results(results)
118 after = set(results)
119 return results, [name for name, _ in objects], after - before

Callers 1

mainFunction · 0.80

Calls 7

maxClass · 0.85
import_implMethod · 0.80
init_classMethod · 0.45
popMethod · 0.45
itemsMethod · 0.45
appendMethod · 0.45
update_resultsMethod · 0.45

Tested by

no test coverage detected