Skip to content

Instantly share code, notes, and snippets.

@maguec
Created January 28, 2022 18:05
Show Gist options
  • Save maguec/281e82ae79ee4e61d5d1fa138c748bf9 to your computer and use it in GitHub Desktop.
Save maguec/281e82ae79ee4e61d5d1fa138c748bf9 to your computer and use it in GitHub Desktop.
print a table
#!/usr/bin/python
import sys
import json
import glob
def print_help(x):
print("Usage: <path> <stat>")
print("\t Stats: {}".format(",".join(x)))
sys.exit(1)
params = {
"Count": 1,
"Ops/sec": 1,
"Hits/sec": 1,
"Misses/sec": 1,
"MOVED/sec": 1,
"ASK/sec": 1,
"KB/sec": 1,
"Latency": 0,
"Average_Latency": 0,
"Min_Latency": 0,
"Max_Latency": 0,
}
if len(sys.argv) < 3:
print_help(params.keys())
path = sys.argv[1]
myParam = sys.argv[2]
if myParam not in params.keys():
print_help(params.keys())
print( "{} {} {} {}".format( myParam, 'clients', 'threads', 'pipeline' ) )
data = []
for f1 in glob.glob("{}/*.json".format(path)):
f1json = json.load(open(f1))
data.append([
f1json['ALL STATS']['Totals'][myParam.replace("_", " ")],
f1json['configuration']['clients'],
f1json['configuration']['threads'],
f1json['configuration']['pipeline'],
])
data.sort(key=lambda x: x[0])
if params[myParam] > 0:
data.reverse()
for x in data :
print( "{} {} {} {}".format( x[0], x[1], x[2], x[3] ) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment