File: frame_info.py

package info (click to toggle)
python-pyinstrument 5.1.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,620 kB
  • sloc: python: 6,713; ansic: 897; makefile: 46; sh: 20; javascript: 18
file content (23 lines) | stat: -rw-r--r-- 536 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from __future__ import annotations

import inspect
from timeit import Timer
from types import FrameType
from typing import Final

from pyinstrument.low_level.stat_profile import get_frame_info

frame: Final[FrameType | None] = inspect.currentframe()
assert frame


def test_func():
    get_frame_info(frame)


t = Timer(stmt=test_func)
test_func_timings = t.repeat(number=400000)

print("min time", min(test_func_timings))
print("max time", max(test_func_timings))
print("average time", sum(test_func_timings) / len(test_func_timings))