-
Notifications
You must be signed in to change notification settings - Fork 13
/
performance_inspect.py
50 lines (37 loc) · 1.13 KB
/
performance_inspect.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
45
46
47
48
49
50
#!/usr/bin/python
import ut
from tkinter import *
from colony_ant_simulator import *
import colony_ant_simulator
import cProfile
import pstats
# TEST PARAMS
colony_ant_simulator.nb_ant = 1000
profile = cProfile.Profile()
def test():
root = Tk()
root.title("Ant Colony Simulator")
root.bind("<Escape>", lambda quit: root.destroy())
environment = Canvas(
root, width=e_w, height=e_h, background="#000028")
environment.pack()
# Initialization of the nest
nest = Nest(environment)
# Initialization of the food
food = Food(environment)
# Birth of ants
ant_data = [] # List contains all ants object
for i in range(colony_ant_simulator.nb_ant):
ant = Ant(nest, environment)
ant_data.append(ant)
# Initiates the movement of ants in the environment after the creation of the environment
# environment.after(
# 1, f_move(environment, ant_data, food))
for i in range(100):
f_move(environment, ant_data, food)
# root.destroy()
root.mainloop()
if __name__ == "__main__":
profile.runcall(test)
ps = pstats.Stats(profile)
ps.print_stats()