only retrieve stack frames we need -- ~2x speed up of test_caller_fmv_fcvt
authorJacob Lifshay <programmerjake@gmail.com>
Fri, 19 May 2023 01:46:57 +0000 (18:46 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Fri, 19 May 2023 02:00:39 +0000 (19:00 -0700)
src/openpower/test/common.py

index e4bded79cc9cb0dae41106bfbad3fc3bc4b8d73c..d6ee02b92f7253b4eece3092e275030011a2207d 100644 (file)
@@ -4,7 +4,7 @@ Bugreports:
 """
 
 from contextlib import contextmanager
-import inspect
+import sys
 import functools
 import types
 import os
@@ -125,11 +125,11 @@ class TestAccumulatorBase:
                  initial_fpscr=None,
                  src_loc_at=0):
 
+        c = sys._getframe(1 + src_loc_at).f_code
         # name of caller of this function
-        test_name = inspect.stack()[1 + src_loc_at][3]
+        test_name = c.co_name
         # name of file containing test case
-        test_file = os.path.splitext(os.path.basename(
-                                    inspect.stack()[1][1]))[0]
+        test_file = os.path.splitext(os.path.basename(c.co_filename))[0]
         tc = TestCase(prog, test_name,
                       regs=initial_regs, sprs=initial_sprs, cr=initial_cr,
                       msr=initial_msr,