plotdats.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. client_analyticals = {
  16. 'singlepass_merkle': '729.8*ceil(log(x)/log(2)) + 16211.1',
  17. 'singlepass_threshsig': '17261.3000000000',
  18. 'telescoping_merkle': '729.8*ceil(log(x)/log(2)) + 15090.1',
  19. 'telescoping_threshsig': '16126.5000000000',
  20. 'vanilla_none': '38.53524*x + 8735.66',
  21. }
  22. plots = [
  23. ('dirauth', 'Directory authorities total bytes each', 2, False, None),
  24. ('relay', 'Relay total bytes each', 4, False, None),
  25. ('relay_bf', 'Bootstrapping fallback relays bytes per bw', 6, True, None),
  26. ('relay_f', 'Non-bootstrapping fallback relays bytes per bw', 8, True, None),
  27. ('relay_b', 'Bootstrapping normal relays bytes per bw', 10, True, None),
  28. ('relay_n', 'Non-bootstrapping normal relays bytes per bw', 12, True, None),
  29. ('client', 'Client total bytes each', 14, False, None),
  30. ('client_b', 'Bootstrapping client total bytes', 16, True, None),
  31. ('client_n', 'Non-bootstrapping client total bytes', 18, True, None),
  32. ('dirauth_ss', 'Directory authority total bytes each', 20, True, None),
  33. ('relay_ss', 'Relay total bytes each', 22, True, None),
  34. ('client_ss', 'Client total bytes each', 24, True, client_analyticals),
  35. ('relay_perclient_ss', 'Relay total bytes per client', 26, True, relay_perclient_analyticals),
  36. ('client_ss_wide', 'Client total bytes each', 24, True, client_analyticals),
  37. ('relay_perclient_ss_wide', 'Relay total bytes per client', 26, True, relay_perclient_analyticals),
  38. ]
  39. dats = [
  40. ('vanilla_none', 'Vanilla', 1),
  41. ('singlepass_merkle', 'Sing(M)', 2),
  42. ('telescoping_merkle', 'Tele(M)', 3),
  43. ('singlepass_threshsig', 'Sing(T)', 4),
  44. ('telescoping_threshsig', 'Tele(T)', 5),
  45. ]
  46. for filename, title, col, errbars, analyticals in plots:
  47. if analyticals is None:
  48. analyticals = dict()
  49. if filename[-5:] == '_wide':
  50. ranges = "set xrange [300:300000]\nset logscale xy\nset yrange [10000:]"
  51. else:
  52. ranges = "set xrange [0:2200]\nset yrange [0:]"
  53. gpcode = """set terminal pdf
  54. set output '%s.pdf'
  55. set title '%s'
  56. %s
  57. set key out
  58. set arrow from 6500, graph 0 to 6500, graph 1 nohead lc 0 lw 2
  59. set xlabel "Number of relays"
  60. set style line 1 lw 2 lc 1 pt 1
  61. set style line 2 lw 2 lc 2 pt 1
  62. set style line 3 lw 2 lc 3 pt 1
  63. set style line 4 lw 2 lc 4 pt 1
  64. set style line 5 lw 2 lc 5 pt 1
  65. set style line 10 lw 2 lc 0 dt 2
  66. set style line 11 lw 2 lc 1 dt 2
  67. set style line 12 lw 2 lc 2 dt 2
  68. set style line 13 lw 2 lc 3 dt 2
  69. set style line 14 lw 2 lc 4 dt 2
  70. set style line 15 lw 2 lc 5 dt 2
  71. plot """ % (filename, title, ranges)
  72. firstplot = True
  73. for datname, title, style in dats:
  74. if firstplot is False:
  75. gpcode += ", "
  76. else:
  77. firstplot = False
  78. gpcode += "'%s.dat' using 1:%d with lines ls %d title '%s'" % \
  79. (datname, col, style, title)
  80. if errbars:
  81. gpcode += ", '%s.dat' using 1:%d:%d with errorbars ls %d notitle" % \
  82. (datname, col, col+1, style)
  83. if datname in analyticals:
  84. gpcode += ", %s ls %d notitle" % \
  85. (analyticals[datname], style+10)
  86. if analyticals:
  87. gpcode += ", -100 ls 10 title 'Analytical'"
  88. gp = subprocess.Popen(['gnuplot', '-'], stdin=subprocess.PIPE)
  89. gp.communicate(gpcode.encode('ascii'))