github.com/nyan233/littlerpc@v0.4.6-0.20230316182519-0c8d5c48abaf/core/client/loadbalance/gen_graph.py (about)

     1  import matplotlib.pyplot as plt
     2  
     3  
     4  def get_data_map() -> dict:
     5      return {
     6          "x": [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],
     7          "opt": [10.18, 10.29, 10.11, 10.28, 10.05, 10.40, 10.36, 10.29, 10.34, 10.43, 10.46, 10.37, 10.23, 10.19
     8              , 11.12],
     9          "ops": [117657063, 116729284, 117122374, 100000000, 117891826, 119604872,
    10                  111143166, 117566828, 114062922, 117205842, 117551119, 116705707, 111119160, 107241640, 103490913],
    11      }
    12  
    13  
    14  if __name__ == '__main__':
    15      data_map = get_data_map()
    16      opt_count = 0
    17      ops_count = 0
    18      for k, v in data_map.items():
    19          if k == 'opt':
    20              for k2, v2 in enumerate(v):
    21                  opt_count += v2
    22          elif k == 'ops':
    23              for k2, v2 in enumerate(v):
    24                  ops_count += v2
    25      print("opt avg -> ", opt_count / len(data_map.get('x')))
    26      print("ops avg -> ", ops_count / len(data_map.get('x')))
    27      fig, avs = plt.subplots(2, 1)
    28      fig.suptitle("Balancer Benchmark, 5000 Node--14C/20T")
    29      opt_g = avs[0]
    30      opt_g.set_xlabel("Goroutine Size")
    31      opt_g.set_ylabel("Option complete time/nano second")
    32      opt_g.plot(data_map.get('x'), data_map.get('opt'), linestyle='dashdot', color='red', alpha=1)
    33      ops_g = avs[1]
    34      ops_g.set_xlabel("Goroutine Size")
    35      ops_g.set_ylabel("Option per second")
    36      ops_g.plot(data_map.get('x'), data_map.get('ops'), linestyle='dashdot', color='green', alpha=1)
    37      plt.show()