mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
GH-104584: Plugin optimizer API (GH-105100)
This commit is contained in:
parent
601ae09f0c
commit
4bfa01b9d9
31 changed files with 950 additions and 501 deletions
|
@ -1916,6 +1916,19 @@ class Test_Pep523API(unittest.TestCase):
|
|||
names = ["func", "outer", "outer", "inner", "inner", "outer", "inner"]
|
||||
self.do_test(func, names)
|
||||
|
||||
class TestOptimizerAPI(unittest.TestCase):
|
||||
|
||||
def test_counter_optimizer(self):
|
||||
opt = _testinternalcapi.get_counter_optimizer()
|
||||
self.assertEqual(opt.get_count(), 0)
|
||||
try:
|
||||
_testinternalcapi.set_optimizer(opt)
|
||||
self.assertEqual(opt.get_count(), 0)
|
||||
for _ in range(1000):
|
||||
pass
|
||||
self.assertEqual(opt.get_count(), 1000)
|
||||
finally:
|
||||
_testinternalcapi.set_optimizer(None)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue