xref: /aosp_15_r20/external/crosvm/tools/contrib/cros_tracing_analyser/histogram.py (revision bb4ee6a4ae7042d18b07a98463b9c8b875e44b39)
1# Copyright 2023 The ChromiumOS Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import json
6import matplotlib.pyplot as plt
7import argparse
8
9parser = argparse.ArgumentParser()
10parser.add_argument("input_json", help="create histogram from input_json")
11args = parser.parse_args()
12
13with open(args.input_json) as f:
14    data = json.load(f)
15for key in data.keys():
16    plt.hist(data[key], bins=len(data[key]))
17    plt.title(key)
18    plt.xlabel("latency")
19    plt.ylabel("number of requests")
20    plt.show(block=True)
21