gen-performance-graph 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 main():
  32. theme.get_options()
  33. theme.output_format = 'pdf'
  34. theme.use_color = 1
  35. theme.reinitialize()
  36. #print >> sys.stderr, dir(theme)
  37. width = 800
  38. height = width * 4 // 5
  39. can = canvas.default_canvas()
  40. size = (width, height)
  41. ar = area.T(size = size, legend=legend.T(), x_axis = axis.X(format="%d", label="Set size"), y_axis = axis.Y(format="%d", label="Time"))
  42. array_timing_data = get_array_timing()
  43. print >> sys.stderr, array_timing_data
  44. lp = line_plot.T(data=array_timing_data, label="Array")
  45. ar.add_plot(lp)
  46. ar.draw()
  47. seek_timing_data = get_seek_timing()
  48. print >> sys.stderr, seek_timing_data
  49. lp = line_plot.T(data=seek_timing_data, label="Seek")
  50. ar.add_plot(lp)
  51. ar.draw()
  52. #can.show(ar.x_pos(4), ar.y_pos(970), "/a50{}seek")
  53. main()