plotdats.py 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/usr/bin/env python3
  2. import subprocess
  3. # Plot the dat files generated by parselogs.py using gnuplot
  4. if __name__ == '__main__':
  5. # The analytical functions come from analytical.py
  6. # Replace 'R' in the output of that program by 'x' and replace
  7. # 'logR' by 'ceil(log(x)/log(2))'.
  8. relay_perclient_analyticals = {
  9. 'singlepass_merkle': '0.020524244*x + 1459.6*ceil(log(x)/log(2)) + 43404.140896',
  10. 'singlepass_threshsig': '0.9048*x + 45628.912096',
  11. 'telescoping_merkle': '0.017528004*x + 1459.6*ceil(log(x)/log(2)) + 36977.500696',
  12. 'telescoping_threshsig': '0.7982*x + 39135.071896',
  13. 'vanilla_none': '38.551644414*x + 25316.281696',
  14. }
  15. relay_analyticals = {
  16. k: '(2500000/6500)*(%s)' % v for k, v in relay_perclient_analyticals.items()
  17. }
  18. client_analyticals = {
  19. 'singlepass_merkle': '729.8*ceil(log(x)/log(2)) + 16211.1',
  20. 'singlepass_threshsig': '17261.3000000000',
  21. 'telescoping_merkle': '729.8*ceil(log(x)/log(2)) + 15090.1',
  22. 'telescoping_threshsig': '16126.5000000000',
  23. 'vanilla_none': '38.53524*x + 8735.66',
  24. }
  25. plots = [
  26. ('dirauth', 'Directory authorities total bytes each', 2, False, None),
  27. ('relay', 'Relay total bytes each', 4, False, None),
  28. ('relay_bf', 'Bootstrapping fallback relays bytes per bw', 6, True, None),
  29. ('relay_f', 'Non-bootstrapping fallback relays bytes per bw', 8, True, None),
  30. ('relay_b', 'Bootstrapping normal relays bytes per bw', 10, True, None),
  31. ('relay_n', 'Non-bootstrapping normal relays bytes per bw', 12, True, None),
  32. ('client', 'Client total bytes each', 14, False, None),
  33. ('client_b', 'Bootstrapping client total bytes', 16, True, None),
  34. ('client_n', 'Non-bootstrapping client total bytes', 18, True, None),
  35. ('dirauth_ss', 'Directory authority total bytes each', 20, True, None),
  36. ('relay_ss', 'Relay total bytes each', 22, True, relay_analyticals),
  37. ('client_ss', 'Client total bytes each', 24, True, client_analyticals),
  38. ('relay_perclient_ss', 'Relay total bytes per client', 26, True, relay_perclient_analyticals),
  39. ('relay_ss_wide', 'Relay total bytes each', 22, True, relay_analyticals),
  40. ('client_ss_wide', 'Client total bytes each', 24, True, client_analyticals),
  41. ('relay_perclient_ss_wide', 'Relay total bytes per client', 26, True, relay_perclient_analyticals),
  42. ]
  43. dats = [
  44. ('vanilla_none', 'Vanilla', 1),
  45. ('singlepass_merkle', 'Sing(M)', 2),
  46. ('telescoping_merkle', 'Tele(M)', 3),
  47. ('singlepass_threshsig', 'Sing(T)', 4),
  48. ('telescoping_threshsig', 'Tele(T)', 5),
  49. ]
  50. for filename, title, col, errbars, analyticals in plots:
  51. if analyticals is None:
  52. analyticals = dict()
  53. if filename == 'relay_ss_wide':
  54. ranges = "set xrange [300:650000]\nset logscale xy\nset yrange [10000000:]"
  55. elif filename[-5:] == '_wide':
  56. ranges = "set xrange [300:650000]\nset logscale xy\nset yrange [10000:]"
  57. else:
  58. ranges = "set xrange [0:2200]\nset yrange [0:]"
  59. gpcode = """set terminal pdf font "DejaVuSans,14" size 5,2.25
  60. set output '%s.pdf'
  61. set title '%s'
  62. %s
  63. set key out
  64. set rmargin 17
  65. set arrow from 6500, graph 0 to 6500, graph 1 nohead lc 0 lw 2
  66. set xlabel "Number of relays"
  67. set style line 1 lw 2 lc 1 pt 1
  68. set style line 2 lw 2 lc 2 pt 1
  69. set style line 3 lw 2 lc 3 pt 1
  70. set style line 4 lw 2 lc 4 pt 1
  71. set style line 5 lw 2 lc 5 pt 1
  72. set style line 10 lw 2 lc 0 dt 2
  73. set style line 11 lw 2 lc 1 dt 2
  74. set style line 12 lw 2 lc 2 dt 2
  75. set style line 13 lw 2 lc 3 dt 2
  76. set style line 14 lw 2 lc 4 dt 2
  77. set style line 15 lw 2 lc 5 dt 2
  78. plot """ % (filename, title, ranges)
  79. firstplot = True
  80. for datname, title, style in dats:
  81. if firstplot is False:
  82. gpcode += ", "
  83. else:
  84. firstplot = False
  85. gpcode += "'%s.dat' using 1:%d with lines ls %d title '%s'" % \
  86. (datname, col, style, title)
  87. if errbars:
  88. gpcode += ", '%s.dat' using 1:%d:%d with errorbars ls %d notitle" % \
  89. (datname, col, col+1, style)
  90. if datname in analyticals:
  91. gpcode += ", %s ls %d notitle" % \
  92. (analyticals[datname], style+10)
  93. if analyticals:
  94. gpcode += ", -100 ls 10 title 'Analytical'"
  95. gp = subprocess.Popen(['gnuplot', '-'], stdin=subprocess.PIPE)
  96. gp.communicate(gpcode.encode('ascii'))