]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/scripts/histogram.py
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / scripts / histogram.py
1 #!/usr/bin/env python3
2
3 import sys
4 import json
5 import base64
6 import struct
7
8 buf = sys.stdin.readlines()
9 json = json.loads(" ".join(buf))
10 histogram = base64.b64decode(json["histogram"])
11 bucket_shift = json["bucket_shift"]
12 tsc_rate = json["tsc_rate"]
13
14 print("Latency histogram")
15 print("==============================================================================")
16 print(" Range in us Cumulative IO count")
17
18 so_far = 0
19 bucket = 0
20 total = 1
21
22 for 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
27 for 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))