Commit 9fb3ab73 authored by John Zhang's avatar John Zhang

separating plot script and performance measurement script

parent 12515743
......@@ -279,46 +279,6 @@ def test_functional_arraysum():
def test_functional_quicksort():
save_results('quicksort', perf_quicksort(100, 5))
def plot(result_dic):
import matplotlib.pyplot as plt
fig = plt.figure(1, figsize=(9, 6))
ax = fig.add_subplot(111)
width = 0.1
colors = ['#718c00',
'#eab700',
'#f5871f',
'#c82829',
'#3e999f',
'#4271ae',
'#8959a8',
'#1d1f21']
all_targets = ('cpython', 'pypy', 'pypy_nojit', 'rpy_c', 'rpy_mu', 'c')
compiled_targets = ('rpy_c', 'rpy_mu', 'c', 'mu')
targets = compiled_targets
data = [(tgt, result_dic[tgt]['average'], result_dic[tgt]['std_dev'])
for tgt in targets]
data.sort(key=lambda (tgt, avg, std): avg)
ratio = [avg / data[0][1] for (_, avg, _std) in data]
for i, (tgt, avg, std_dev) in enumerate(data):
ax.bar(width / 2 + width * i, avg, width, color=colors[i], yerr=std_dev, label=tgt)
ax.text(width / 2 + width * i + 0.01, avg, "%.6f" % avg, color='#1d1f21', fontweight='bold')
ax.text(width * (i + 1), avg - std_dev, "%.6f" % std_dev, color='#1d1f21', fontweight='bold')
ax.text(width * (i + 1) - 0.02, avg / 2, "%.3fx" % ratio[i], color='#1d1f21', fontweight='bold')
# plt.legend(loc=2)
plt.xticks([width * (i + 1) for i in range(len(targets))], [tgt for (tgt, _, _) in data])
plt.title("%(test_name)s with input size %(input_size)d" % result_dic)
plt.show()
def test_plot():
# plot(perf_quicksort(1000, 20))
import json
with open('result_quicksort.json', 'r') as fp:
plot(json.load(fp))
if __name__ == '__main__':
import sys
N = int(sys.argv[1])
......@@ -327,4 +287,3 @@ if __name__ == '__main__':
# arraysum_res = perf_arraysum(1000000, 20)
# save_results('arraysum', arraysum_res)
quicksort_res = perf_quicksort(N, 100)
plot(quicksort_res)
import sys, json
import matplotlib.pyplot as plt
def plot(result_dic):
fig = plt.figure(1, figsize=(9, 6))
ax = fig.add_subplot(111)
width = 0.1
colors = ['#718c00',
'#eab700',
'#f5871f',
'#c82829',
'#3e999f',
'#4271ae',
'#8959a8',
'#1d1f21']
all_targets = ('cpython', 'pypy', 'pypy_nojit', 'rpy_c', 'rpy_mu', 'c')
compiled_targets = ('rpy_c', 'rpy_mu', 'c', 'mu')
targets = compiled_targets
data = [(tgt, result_dic[tgt]['average'], result_dic[tgt]['std_dev'])
for tgt in targets]
data.sort(key=lambda (tgt, avg, std): avg)
ratio = [avg / data[0][1] for (_, avg, _std) in data]
for i, (tgt, avg, std_dev) in enumerate(data):
ax.bar(width / 2 + width * i, avg, width, color=colors[i], yerr=std_dev, label=tgt)
ax.text(width / 2 + width * i + 0.01, avg, "%.6f" % avg, color='#1d1f21', fontweight='bold')
ax.text(width * (i + 1), avg - std_dev, "%.6f" % std_dev, color='#1d1f21', fontweight='bold')
ax.text(width * (i + 1) - 0.02, avg / 2, "%.3fx" % ratio[i], color='#1d1f21', fontweight='bold')
# plt.legend(loc=2)
plt.xticks([width * (i + 1) for i in range(len(targets))], [tgt for (tgt, _, _) in data])
plt.title("%(test_name)s with input size %(input_size)d" % result_dic)
plt.show()
def test_plot():
# plot(perf_quicksort(1000, 20))
with open('result_quicksort.json', 'r') as fp:
plot(json.load(fp))
if __name__ == '__main__':
with open(sys.argv[1], 'r') as fp:
plot(json.load(fp))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment