Advertisement
Guest User

histo

a guest
Oct 16th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import csv
  3. import numpy as np
  4.  
  5. measures = 10
  6.  
  7. x = []
  8. y = []
  9. x2 = []
  10. y2 = []
  11.  
  12. # Python program to get average of a list
  13. def Average(y):
  14. return sum(y) / len(y)
  15.  
  16. def LoadCSV(type):
  17. if type == "mysql":
  18. file = "postgresql.csv"
  19. with open(file, 'r') as csvfile:
  20. plots = csv.reader(csvfile, delimiter=',')
  21. next(plots, None)
  22. for row in plots:
  23. x.append(int(row[0]))
  24. y.append(int(row[1]))
  25. elif type == "postgresql":
  26. file = "postgresql.csv"
  27. with open(file, 'r') as csvfile:
  28. plots = csv.reader(csvfile, delimiter=',')
  29. next(plots, None)
  30. for row in plots:
  31. x2.append(int(row[0]))
  32. y2.append(int(row[1]))
  33.  
  34.  
  35. LoadCSV("mysql")
  36. LoadCSV("postgresql")
  37.  
  38. average = round(Average(y))
  39.  
  40.  
  41. plt.subplot(2, 1, 1)
  42. num_bins = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]
  43. n, bins, patches = plt.hist(y, num_bins, facecolor='blue', alpha=0.5, edgecolor='black', linewidth=1.2, label="postgresql")
  44. plt.xlabel("Searchtime (ms)")
  45. plt.ylabel('Frequency')
  46. plt.title('Average Searchtimes\n(Out of 10)')
  47. plt.legend();
  48. plt.grid(axis='y', alpha=0.75)
  49. plt.xticks(np.arange(0, 1000, step=100))
  50. plt.yticks(np.arange(0, 2000, step=100))
  51.  
  52. plt.subplot(2, 1, 2)
  53. n, bins, patches = plt.hist(y2, num_bins, facecolor='orange', alpha=0.5, edgecolor='black', linewidth=1.2, label="PostgreSQL")
  54. plt.xlabel("Searchtime (ms)")
  55. plt.ylabel('Frequency')
  56. plt.legend();
  57. plt.grid(axis='y', alpha=0.75)
  58. plt.xticks(np.arange(0, 1000, step=100))
  59. plt.yticks(np.arange(0, 2000, step=100))
  60.  
  61. plt.show()
  62.  
  63. print(x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement