File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed
Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -11,17 +11,16 @@ def performance(func):
1111 setattr (performance ,"total_mem" ,0 )
1212
1313 def _d1 ():
14- memory_used = sys .getsizeof (func )
15- start_time = time .time_ns ()
16- func ()
17- performance .counter += 1
18- end_time = time .time_ns ()
19- elapsed = 0
14+ tracemalloc .start ()
15+ start_time = time .perf_counter ()
16+ result = func (* args ,** kwargs )
17+ end_time = time .perf_counter ()
2018 elapsed = end_time - start_time
21- performance .total_time += (int )(elapsed / 1e9 )
22- performance .total_mem += memory_used
23- return (performance .counter , performance .total_time , performance .total_mem )
24-
19+ current_mem , peak_mem = tracemalloc .get_traced_memory ()
20+ performance .counter += 1
21+ performance .total_time += elapsed
22+ performance .total_mem += peak_mem
23+ return result
2524 return _d1
2625
2726
You can’t perform that action at this time.
0 commit comments