forked from reims/wesen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.py
executable file
·33 lines (25 loc) · 940 Bytes
/
profile.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
#! /usr/bin/python3
"""This profiling routine was used to identify bottlenecks,
then in objects.base the getRange method was optimized.
It still is the main bottleneck,
but there seems to be no potential for further optimization.
Now you should modify/copy this file,
to profile your AI source code.
In some tournaments, there is a penalty for computation cost."""
from src.Wesen.loader import Loader
from cProfile import Profile
from time import perf_counter
# only in python3.3
from pstats import Stats
import sys
print("You can supply an alternative config file on the command-line")
print("You should stop Wesen by Ctrl+C to finish profiling")
sys.argv.append('--disablegui')
pr = Profile(perf_counter)
pr.run('Loader()')
pr.dump_stats('profile.stats')
# you may explore profile.stats with the pstats browser.
stats = Stats(pr)
stats.sort_stats('tottime')
# stats.print_stats('Wesen/sources',10)
stats.print_stats('Wesen/', 10)