-
Notifications
You must be signed in to change notification settings - Fork 4
/
draw.py
46 lines (39 loc) · 1.15 KB
/
draw.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
#!/bin/python
'''
File name: draw.py
Author: Bae Jiun, Maybe
Date created: 10/27/2017
Requirements:
- matplotlib
'''
from subprocess import Popen, PIPE
from os import environ, name
import matplotlib
if not (name == 'nt' or 'DISPLAY' in environ):
matplotlib.use('Agg')
TARGET = "run"
RANGE = [1, 2, 4, 8, 16, 32]
print ("Execute target file:", TARGET)
print ("Execute range:", RANGE)
def execute(count):
def parse(out):
if ':' in out: return int(out.split(':')[1])
return int(out)
process = Popen(["./" + TARGET, str(count)], stdout=PIPE, stderr=PIPE)
stdout, stderr = process.communicate()
if stderr:
raise Exception('Error while running {} {}'.format(TARGET, count), stderr)
return parse(stdout.decode("utf-8"))
import matplotlib.pyplot as plt
fig = plt.figure()
for x, y in zip(RANGE, map(execute, RANGE)):
print ("Result update count: {} in thread count: {}".format(y, x))
plt.scatter(x, y, color='BLACK')
# change y range if you need
# plt.ylim((25,250))
plt.xlabel("thread")
plt.ylabel("update")
plt.savefig('result.png')
if name == 'nt' or 'DISPLAY' in environ:
plt.show()
plt.close()