-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmem_tester.py
More file actions
43 lines (30 loc) · 844 Bytes
/
mem_tester.py
File metadata and controls
43 lines (30 loc) · 844 Bytes
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
import os
import sys
import shutil
from StringIO import StringIO
import time
os.system('mprof clean')
for i in range(100):
time.sleep(1)
# Setup
if os.path.exists('./delegates'):
shutil.rmtree('./delegates')
if os.path.exists('./routes'):
shutil.rmtree('./routes')
if os.path.exists('./generated'):
shutil.rmtree('./generated')
oldstdout = sys.stdout
out = StringIO()
sys.stdout = out
# Memory test
os.system('mprof run --interval 0.005 python2 mem_tested.py')
# Cleanup
sys.stdout = oldstdout
if os.path.exists('./delegates'):
shutil.rmtree('./delegates')
if os.path.exists('./routes'):
shutil.rmtree('./routes')
if os.path.exists('./generated'):
shutil.rmtree('./generated')
# Graph
# os.system('mprof plot')