2
0

perf_gso.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/usr/bin/python
  2. #
  3. # Copyright (c) 2013-2021 Winlin
  4. #
  5. # SPDX-License-Identifier: MIT
  6. #
  7. import urllib, sys, json
  8. url = "http://localhost:1985/api/v1/perf"
  9. if len(sys.argv) < 2:
  10. print "Usage: %s <url>"%(sys.argv[0])
  11. print "For example:"
  12. print " %s http://localhost:1985/api/v1/perf"%(sys.argv[0])
  13. sys.exit(-1)
  14. url = sys.argv[1]
  15. print "Open %s"%(url)
  16. f = urllib.urlopen(url)
  17. s = f.read()
  18. f.close()
  19. print "Repsonse %s"%(s)
  20. obj = json.loads(s)
  21. print ""
  22. p = obj['data']['dropped']
  23. print('Frame-Dropped: %.1f%s'%(10000.0 * p['rtc_dropeed'] / p['rtc_frames'], '%%'))
  24. p = obj['data']['bytes']
  25. print('Padding-Overload: %.1f%s %dMB'%(10000.0 * p['rtc_padding'] / p['rtc_bytes'], '%%', p['rtc_padding']/1024/1024))
  26. # 2, 3, 5, 9, 16, 32, 64, 128, 256
  27. keys = ['lt_2', 'lt_3', 'lt_5', 'lt_9', 'lt_16', 'lt_32', 'lt_64', 'lt_128', 'lt_256', 'gt_256']
  28. print("\n----------- 1 2 [3,4] [5,8] [9,15] [16,31] [32,63] [64,127] [128,255] [256,+) Packets"),
  29. print ""
  30. print("AV---Frames"),
  31. p = obj['data']['avframes']
  32. for k in keys:
  33. k2 = '%s'%(k)
  34. if k2 in p:
  35. print(p[k2]),
  36. else:
  37. print(0),
  38. print(p['nn']),
  39. print ""
  40. print("RTC--Frames"),
  41. p = obj['data']['rtc']
  42. for k in keys:
  43. k2 = '%s'%(k)
  44. if k2 in p:
  45. print(p[k2]),
  46. else:
  47. print(0),
  48. print(p['nn']),
  49. print ""
  50. print("RTP-Packets"),
  51. p = obj['data']['rtp']
  52. for k in keys:
  53. k2 = '%s'%(k)
  54. if k2 in p:
  55. print(p[k2]),
  56. else:
  57. print(0),
  58. print(p['nn']),
  59. print ""
  60. print("GSO-Packets"),
  61. p = obj['data']['gso']
  62. for k in keys:
  63. k2 = '%s'%(k)
  64. if k2 in p:
  65. print(p[k2]),
  66. else:
  67. print(0),
  68. print(p['nn']),