forked from redruin1/factorio-draftsman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofiler.py
44 lines (32 loc) · 947 Bytes
/
profiler.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# profiler.py
"""
Profiling script used to test the performance of the module.
"""
import cProfile, pstats
import unittest
from pstats import SortKey
# from pyinstrument import Profiler
import timeit
# from test.performance.set_signal import main as test_main
def main():
profiler = cProfile.Profile()
# profiler = Profiler(interval=0.0001)
test_loader = unittest.TestLoader()
tests = test_loader.discover("test")
test_runner = unittest.TextTestRunner()
profiler.enable()
# profiler.start()
test_runner.run(tests)
# start = timeit.default_timer()
# test_main()
# stop = timeit.default_timer()
profiler.disable()
# profiler.stop()
stats = pstats.Stats(profiler).sort_stats(SortKey.PCALLS)
stats.print_stats(0.1)
stats.sort_stats(SortKey.CUMULATIVE)
stats.print_stats(0.1)
# profiler.open_in_browser()
# print(stop - start)
if __name__ == "__main__":
main()