Last active
August 29, 2015 14:18
-
-
Save jolynch/eddcd329b3c754f5b0b2 to your computer and use it in GitHub Desktop.
Hacky script to convert an apache benchmark data file into a CDF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Usage | |
# ./convert_to_cdf.py ab_output.dat ab_output_cdf.dat | |
import csv | |
import sys | |
times = [] | |
just_times = [] | |
infile = sys.argv[1] | |
outfile = sys.argv[2] | |
with open(infile, 'r') as f: | |
next(f) | |
reader = csv.reader(f, delimiter='\t') | |
for st, s, ctime, dtime, ttime, wait in reader: | |
times.append((s, ttime)) | |
just_times.append(ttime) | |
with open(outfile, 'w') as f: | |
writer = csv.writer(f, delimiter='\t') | |
writer.writerow(('ms', 'percent')) | |
num = float(len(times)) | |
seen = {} | |
rows = [] | |
for s, ttime in times: | |
if ttime in seen: | |
continue | |
rows.append((ttime, '{:.6f}'.format(just_times.count(ttime) / num))) | |
seen[ttime] = True | |
writer.writerows(rows) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment