Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- import csv
- import numpy as np
- measures = 10
- x = []
- y = []
- x2 = []
- y2 = []
- # Python program to get average of a list
- def Average(y):
- return sum(y) / len(y)
- def LoadCSV(type):
- if type == "mysql":
- file = "postgresql.csv"
- with open(file, 'r') as csvfile:
- plots = csv.reader(csvfile, delimiter=',')
- next(plots, None)
- for row in plots:
- x.append(int(row[0]))
- y.append(int(row[1]))
- elif type == "postgresql":
- file = "postgresql.csv"
- with open(file, 'r') as csvfile:
- plots = csv.reader(csvfile, delimiter=',')
- next(plots, None)
- for row in plots:
- x2.append(int(row[0]))
- y2.append(int(row[1]))
- LoadCSV("mysql")
- LoadCSV("postgresql")
- average = round(Average(y))
- plt.subplot(2, 1, 1)
- num_bins = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]
- n, bins, patches = plt.hist(y, num_bins, facecolor='blue', alpha=0.5, edgecolor='black', linewidth=1.2, label="postgresql")
- plt.xlabel("Searchtime (ms)")
- plt.ylabel('Frequency')
- plt.title('Average Searchtimes\n(Out of 10)')
- plt.legend();
- plt.grid(axis='y', alpha=0.75)
- plt.xticks(np.arange(0, 1000, step=100))
- plt.yticks(np.arange(0, 2000, step=100))
- plt.subplot(2, 1, 2)
- n, bins, patches = plt.hist(y2, num_bins, facecolor='orange', alpha=0.5, edgecolor='black', linewidth=1.2, label="PostgreSQL")
- plt.xlabel("Searchtime (ms)")
- plt.ylabel('Frequency')
- plt.legend();
- plt.grid(axis='y', alpha=0.75)
- plt.xticks(np.arange(0, 1000, step=100))
- plt.yticks(np.arange(0, 2000, step=100))
- plt.show()
- print(x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement