]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/scripts/histogram.py
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / scripts / histogram.py
CommitLineData
9f95a23c
TL
1#!/usr/bin/env python3
2
3import sys
4import json
5import base64
6import struct
7
8buf = sys.stdin.readlines()
9json = json.loads(" ".join(buf))
10histogram = base64.b64decode(json["histogram"])
11bucket_shift = json["bucket_shift"]
12tsc_rate = json["tsc_rate"]
13
14print("Latency histogram")
15print("==============================================================================")
16print(" Range in us Cumulative IO count")
17
18so_far = 0
19bucket = 0
20total = 1
21
22for i in range(0, 64 - bucket_shift):
23 for j in range(0, (1 << bucket_shift)):
24 index = (((i << bucket_shift) + j) * 8)
25 total += int.from_bytes(histogram[index:index + 8], 'little')
26
27for i in range(0, 64 - bucket_shift):
28 for j in range(0, (1 << bucket_shift)):
29 index = (((i << bucket_shift) + j)*8)
30 count = int.from_bytes(histogram[index:index + 8], 'little')
31 so_far += count
32 last_bucket = bucket
33
34 if i > 0:
35 bucket = (1 << (i + bucket_shift - 1))
36 bucket += ((j+1) << (i - 1))
37 else:
38 bucket = j+1
39
40 start = last_bucket * 1000 * 1000 / tsc_rate
41 end = bucket * 1000 * 1000 / tsc_rate
42 so_far_pct = so_far * 100.0 / total
43 if count > 0:
44 print("%9.3f - %9.3f: %9.4f%% (%9u)" % (start, end, so_far_pct, count))