Timings and percentiles

import numpy as np import pandas as pd last_n = 10 thresholds = [50, 95, 99, 99.9] timings_ms = [820, 932, 783, 796, 812, 1023, 1112, 1030, 866, 892, 917, 1002, 1063, 1020, 975, 808, 912, 973] df = pd.DataFrame({'timings_ms': timings_ms}) for threshold in thresholds: print('{0}th percentile: {1:.2f}'.format(threshold, np.percentile(timings_ms, threshold))) """ 50th percentile: 924.50 95th percentile: 1070.35 99th percentile: 1103.67 99.9th percentile: 1111.17 """ for threshold in thresholds: print('Rolling percentile ({0}th): {1}'.format( threshold, df.rolling(last_n).quantile(threshold/100).dropna()['timings_ms'].tolist() )) """ Rolling percentile (50th): [866.0, 892.0, 892.0, 917.0, 1002.0, 1002.0, 975.0, 917.0, 917.0] Rolling percentile (95th): [1030.0, 1030.0, 1030.0, 1063.0, 1063.0, 1063.0, 1063.0, 1030.0, 1020.0] Rolling percentile (99th): [1030.0, 1030.0, 1030.0, 1063.0, 1063.0, 1063.0, 1063.0, 1030.0, 1020.0] Rolling percentile (99.9th): [1030.0, 1030.0, 1030.0, 1063.0, 1063.0, 1063.0, 1063.0, 1030.0, 1020.0] """ Observing 50th percentile(median) change over time