gen-performance-graph 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/usr/bin/python
  2. #
  3. # Copyright (C) 2000-2005 by Yasushi Saito (yasushi.saito@gmail.com)
  4. #
  5. # Pychart is free software; you can redistribute it and/or modify it
  6. # under the terms of the GNU General Public License as published by the
  7. # Free Software Foundation; either version 2, or (at your option) any
  8. # later version.
  9. #
  10. # Pychart is distributed in the hope that it will be useful, but WITHOUT
  11. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  13. # for more details.
  14. #
  15. import sys
  16. from pychart import *
  17. def get_timing(filename):
  18. file_ = open(filename, 'r')
  19. list_ = []
  20. for line in file_:
  21. fields = line.split()
  22. set_size = float(fields[0])
  23. duration = float(fields[1])
  24. list_.append( ( set_size, duration ) )
  25. file_.close()
  26. return list_
  27. def get_array_timing():
  28. return get_timing('array.txt')
  29. def get_seek_timing():
  30. return get_timing('seek.txt')
  31. def desired_y_max(*list_):
  32. maximum = 0.0
  33. for element in list_:
  34. for set_size, duration in element:
  35. maximum = max(duration, maximum)
  36. return maximum
  37. def main():
  38. theme.get_options()
  39. theme.output_format = 'pdf'
  40. theme.use_color = 1
  41. theme.reinitialize()
  42. width = 800
  43. height = width * 4 // 5
  44. size = (width, height)
  45. array_timing_data = get_array_timing()
  46. seek_timing_data = get_seek_timing()
  47. y_max = desired_y_max(array_timing_data, seek_timing_data)
  48. can = canvas.default_canvas()
  49. ar = area.T(
  50. size = size,
  51. legend=legend.T(),
  52. x_range = (1, None),
  53. y_range = (0.0001, y_max + 100),
  54. x_coord = log_coord.T(),
  55. y_coord = log_coord.T(),
  56. x_axis = axis.X(format="%d", label="Set size"),
  57. y_axis = axis.Y(format="%d", label="Time"),
  58. )
  59. lp = line_plot.T(data=array_timing_data, label="Array")
  60. ar.add_plot(lp)
  61. lp = line_plot.T(data=seek_timing_data, label="Seek")
  62. ar.add_plot(lp)
  63. ar.draw()
  64. #can.show(ar.x_pos(4), ar.y_pos(970), "/a50{}seek")
  65. main()