-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtimer
executable file
·55 lines (42 loc) · 1.36 KB
/
timer
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
51
52
53
54
#! /usr/bin/python3
from statistics import median
import numpy as np
import pandas as pd
import argparse
import subprocess
parser = argparse.ArgumentParser(description='.')
parser.add_argument('-j', '--java', type=str, nargs="+" , required=True)
parser.add_argument("-a", '--args', type=str, nargs="+")
args = parser.parse_args()
bins = vars(args).get("java")
argList = vars(args).get("args")
out = np.zeros((len(bins), len(argList)))
speedup = np.zeros((len(bins)-1, len(argList)))
basetimes = np.zeros(len(argList))
x = 0
y = 0
# Run each java program for each argument
for bin in bins:
for arg in argList:
command = "java " + bin + " " + arg
time = subprocess.check_output(command.split(), stderr=subprocess.PIPE)
time = str(time)[2:len(str(time))-3]
time = str(time).split('\\n')
time.sort()
median = float(time[len(time)//2])/1000
out[x, y] = median
if x == 0:
basetimes[y] = median
else:
speedup[x-1, y] = median / basetimes[y]
y = y + 1
print(bin, arg)
y = 0
x = x + 1
df = pd.DataFrame(out, bins, argList)
df.to_excel("results_2.xlsx", sheet_name="Time tables")
bins.pop(0)
if (len(bins) != 0):
df = pd.DataFrame(speedup, bins, argList)
df.to_excel("results.xlsx", sheet_name="Speedup tables")
print("Tables generated. Check results.xlsx")