Python based ops


format json

using following commands:

echo '{"foo": "bar"}' | python -m json.tool

analyze results from timer



timer1: the time 1.0
timer1: the time 2.0
timer1: the time 3.0


cat testdata.txt |cut -d " " -f 4

之后再将这些数据使用pip传送给python scripts 比如

cat testdata.txt |cut -d " " -f 4 | python3

具体的python scripts如下,需要对于list添加什么样的运算都可以灵活处理,简单直接

import sys
import statistics

data_list = []
real_data_list = []
def isfloat(value):
return True
except ValueError:
return False

for line in sys.stdin:
new_list = [(elem) for elem in line.split()]

#print (data_list)
# delete useless string
for d in (data_list):
if isfloat(d):

#print (real_data_list)
print ("len", len(real_data_list))
print ("avg", statistics.mean(real_data_list))
print ("min", min(real_data_list) )
print ("max", max(real_data_list) )
print ("std",statistics.stdev(real_data_list))
print ("sum",sum(real_data_list))

Actually, python statistical library have provided a function to compute these values at once:

import numpy as np
from scipy.stats import describe
v = np.random.normal(size=100)
res = describe(v)

In addition to these basic descriptions, another description is the statistical significance test, this video shows a good theoretical backgound about the hypothesis testing.

Assuming the that the collected value is the execution time, you may see that 50% of them completed in 1 seconds. However, it is more professional to use the hypothesis testing to show this. Such as the p value to reject the hypothesis is 0.01, null hypothesis is the execution time which is larger then specific threshold.

Using python library can do the ttest quickly, there are flexible parameters to set the left tail testing, right tail testing of double sided testing.