New metric: bank usage ratio

This commit is contained in:
Éder F. Zulian
2016-05-17 17:22:45 +02:00
parent 604f882b5b
commit 88cf6919f7

View File

@@ -219,6 +219,19 @@ def number_of_accesses(connection):
return result[0]
@metric
def bank_usage_ratio(connection):
bankAccess = []
cursor = connection.cursor()
total = number_of_accesses(connection)
for bank in range(getNumberOfBanks(connection)):
cursor.execute("SELECT COUNT(*) FROM Transactions where TBank = {}".format(bank))
r = cursor.fetchone()
bankAccess.append(round((float(r[0]) / float(total)) * 100.0, 2))
return ",".join(format(x, "6.2f") for x in bankAccess)
# @metric
# def number_of_precharges(connection):
# cursor = connection.cursor()