def calculate_percentile(duration, max_qps, cannon: Cannon):
    df = create_dataframe()
    for i in range(100, max_qps, 10):
        latency_list = cannon.start_shoot(max_qps, duration, threads=int(max_qps / 10))
        df.loc[i] = [duration,
                     duration*(i+1),
                     i+1,
                     calc_percentile(.5, latency_list),
                     calc_percentile(.9, latency_list),
                     calc_percentile(.99, latency_list),
                     100*latency_list.count(None)/len(latency_list)]
    return df
예제 #2
0
import logging

from cannon import Cannon

logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)
URL = "http://localhost:8080"

if __name__ == '__main__':
    cannon = Cannon(URL)
    latencies = cannon.start_shoot(qps=100, duration=15, threads=80)
    print(latencies)