File: save_stats.py

package info (click to toggle)
python-yappi 1.6.10-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,612 kB
  • sloc: python: 4,081; ansic: 2,500; makefile: 27
file content (26 lines) | stat: -rw-r--r-- 477 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
24
25
26
import time
import yappi
import _yappi

timings = {"a_1":4, "b_1":1}
_yappi._set_test_timings(timings)

def profile(func):
    def wrapped(*args, **kwargs):
        yappi.start()
        result = func(*args, **kwargs)
        yappi.stop()
        prof_file = f"{func.__name__}.{time.time()}"
        #prof_file = "callgrind.a.1"
        yappi.get_func_stats().save(prof_file, "ystat")
        return result
    return wrapped

def b():
    pass

@profile
def a():
    b()

a()