-
Notifications
You must be signed in to change notification settings - Fork 0
/
edmain.py
43 lines (31 loc) · 997 Bytes
/
edmain.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
"""
main code
TODO Distance: prespawn and keep threads running
TODO FileCahce: cache with class name
TODO MultiDistane: threads in multipath
TODO Distance: tune path length to cache
TODO Distance: print distance name
"""
from __future__ import print_function, unicode_literals
import fileinput
import string
from src.edpath import Distance
def wrap_to_profile(func):
def _wrap(*args, **kwargs):
import cProfile, pstats, StringIO
pr = cProfile.Profile()
pr.enable()
ret = func(*args, **kwargs)
pr.disable()
s = StringIO.StringIO()
sortby = 'cumulative'
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
ps.print_stats()
print(s.getvalue())
return ret
return _wrap
if __name__ == '__main__':
mypath = Distance(string.join(fileinput.input()))
print('Direct path is %.2f ly' % mypath.direct_length)
mypath.print_path(mypath.best_path()[-1])
mypath.print_cache_hit_histogram()