Skip to content

Instantly share code, notes, and snippets.

@rtimmons
Created January 30, 2020 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtimmons/a2ee5cdd58681d973ba470e16314402e to your computer and use it in GitHub Desktop.
Save rtimmons/a2ee5cdd58681d973ba470e16314402e to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import sys
try:
import numpy as np
except:
print(f"numpy not found:\n\tpip install numpy")
sys.exit(1)
"""
Example lines:
timestamp,actor,thread,operation,duration,outcome,n,ops,errors,size
1050011747325,HedgedReadsWithStaggering,302,Find,199137524,0,1,0,0,0
"""
def parse_line(line, actor, operation):
bits = line.strip().split(',')
if len(bits) < 10 or bits[1] != actor or bits[3] != operation:
return (False, 0)
return (True, int(bits[4]))
if len(sys.argv) < 5:
raise Exception(f"Usage: {sys.argv[0]} percentile genny-csv-file actor operation")
percentile, filename, actor, operation = sys.argv[1:5]
with open(filename, 'r') as f:
arr = [parse_line(line, actor, operation) for line in f.readlines()]
arr = [v for (t, v) in arr if t]
arr.sort()
a = np.array(arr)
p = np.percentile(a, int(percentile))
print(p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment