Skip to content

Commit

Permalink
Add runtime of test queries #9
Browse files Browse the repository at this point in the history
  • Loading branch information
JetamZ committed Nov 10, 2024
1 parent a399e6b commit a016ac5
Show file tree
Hide file tree
Showing 32 changed files with 109 additions and 11 deletions.
31 changes: 25 additions & 6 deletions api/client2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import requests
import json
import os
import time

import argparse
from prettytable import PrettyTable
Expand All @@ -25,11 +26,12 @@ def __init__(self, args):
self.interactive = args.interactive

def __process_query(self, query_file):
start_time = time.time()*1000
with open(query_file, 'r') as file:
query = json.load(file)
response = requests.post(self.URL, json=query)

return query['description'], response.json()
end_time = time.time()*1000
return query['description'], response.json(), (end_time - start_time)

def __adjust_results(self, result):
if result:
Expand Down Expand Up @@ -68,7 +70,7 @@ def __graph_results(self, description, result):

def run_specific(self, specific_query):
# print(f"Processing {specific_query} ...")
description, result = self.__process_query(specific_query)
description, result, runtime = self.__process_query(specific_query)
# print(f"Result for {specific_query}:")

res=None
Expand All @@ -80,37 +82,54 @@ def run_specific(self, specific_query):
else:
for res in result:
res = self.__adjust_results(res)
print(f"Running time: {runtime} ms")
print()
print(res)
else:
for res in result:
res = self.__adjust_results(res)
print(f"Running time {runtime} ms")
print()
print(res)

if self.target_dir:
with open(f"{self.target_dir}/{specific_query[:-5]}_result.txt", 'w') as file:
print(result, file=file)
print(file=file)
print(f"Running time {runtime} ms", file=file)
print(file=file)
print(self.__adjust_results(result), file=file)
print(file=file)
print()
res = self.__adjust_results(res)
print(res)

def run(self):
for filename in os.listdir(self.QueryDir):

if filename.endswith(".json"):
query_file = os.path.join(self.QueryDir, filename)
print(f"Processing {query_file} ...")
description, results = self.__process_query(query_file)
description, results, runtime = self.__process_query(query_file)
for result in results:

if self.interactive:
graph = input("Would you like to graph the results?(Y/n)")
if graph == 'Y':
self.__graph_results(description, result)
else:

print(f"Result for {query_file}:")
print(self.__adjust_results(result))

else:
print(result)
print(f"Result for {query_file}:")
print(self.__adjust_results(result))
if self.target_dir:
with open(f"{self.target_dir}{filename[:-5]}_result.txt", 'w') as file:
print(result, file=file)
print(file=file)
print(f"Running time {runtime} ms", file=file)
print(file=file)
res = self.__adjust_results(result)
print(str(res), file=file)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[{'affiliation.person_id': 'AndrejBabis.1954', 'average_named_entity_references': 81.39669421487604}, {'affiliation.person_id': 'VeraJourova.1964', 'average_named_entity_references': 50.0}, {'affiliation.person_id': 'RichardBrabec.1966', 'average_named_entity_references': 36.2}, {'affiliation.person_id': 'JosefKott.1970', 'average_named_entity_references': 22.4390243902439}, {'affiliation.person_id': 'AdamVojtech.1986', 'average_named_entity_references': 21.5}, {'affiliation.person_id': 'KarelHavlicek.1969', 'average_named_entity_references': 18.666666666666668}, {'affiliation.person_id': 'DanTok.1959', 'average_named_entity_references': 16.333333333333332}, {'affiliation.person_id': 'RobertPelikan.1979', 'average_named_entity_references': 16.0}, {'affiliation.person_id': 'JanaMrackovaVildumetzova.1973', 'average_named_entity_references': 12.326923076923077}, {'affiliation.person_id': 'LubomirMetnar.1967', 'average_named_entity_references': 12.0}, {'affiliation.person_id': 'BronislavSchwarz.1966', 'average_named_entity_references': 12.0}, {'affiliation.person_id': 'MarekNovak.1976', 'average_named_entity_references': 12.0}, {'affiliation.person_id': 'KlaraDostalova.1971', 'average_named_entity_references': 11.068965517241379}, {'affiliation.person_id': 'PetrVrana.1975', 'average_named_entity_references': 11.0}, {'affiliation.person_id': 'AlenaSchillerova.1964', 'average_named_entity_references': 10.455696202531646}, {'affiliation.person_id': 'RadekVondracek.1973', 'average_named_entity_references': 10.06561203319502}, {'affiliation.person_id': 'JaroslavFaltynek.1962', 'average_named_entity_references': 7.722614840989399}, {'affiliation.person_id': 'ZdenekSoukup.1952', 'average_named_entity_references': 7.5}, {'affiliation.person_id': 'RomanKubicek.1963', 'average_named_entity_references': 7.4}, {'affiliation.person_id': 'BerenikaPestova.1971', 'average_named_entity_references': 7.333333333333333}, {'affiliation.person_id': 'MiloslavJanulik.1962', 'average_named_entity_references': 7.0}, {'affiliation.person_id': 'IvoVondrak.1959', 'average_named_entity_references': 6.5}, {'affiliation.person_id': 'JiriZlatuska.1957', 'average_named_entity_references': 6.5}, {'affiliation.person_id': 'JosefHajek.1956', 'average_named_entity_references': 6.0}, {'affiliation.person_id': 'JaroslavaPokornaJermanova.1970', 'average_named_entity_references': 5.787781350482315}, {'affiliation.person_id': 'JanaHanzlikova.1966', 'average_named_entity_references': 5.5}, {'affiliation.person_id': 'RobertKralicek.1977', 'average_named_entity_references': 5.0}, {'affiliation.person_id': 'MartinStropnicky.1956', 'average_named_entity_references': 4.1875}, {'affiliation.person_id': 'MartinKolovratnik.1975', 'average_named_entity_references': 3.57847533632287}, {'affiliation.person_id': 'MilanBrazdil.1962', 'average_named_entity_references': 3.3548387096774195}, {'affiliation.person_id': 'RomanaFischerova.1969', 'average_named_entity_references': 3.0}, {'affiliation.person_id': 'JaroslavBzoch.1983', 'average_named_entity_references': 3.0}, {'affiliation.person_id': 'JanVolny.1959', 'average_named_entity_references': 2.1560283687943262}, {'affiliation.person_id': 'JiriBlaha.1961', 'average_named_entity_references': 2.0}, {'affiliation.person_id': 'HelenaValkova.1951', 'average_named_entity_references': 1.3804347826086958}, {'affiliation.person_id': 'RadkaMaxova.1968', 'average_named_entity_references': 1.0}, {'affiliation.person_id': 'MatejFichtner.1984', 'average_named_entity_references': 0.5588235294117647}, {'affiliation.person_id': 'PatrikNacher.1974', 'average_named_entity_references': 0.5}, {'affiliation.person_id': 'OndrejBabka.1994', 'average_named_entity_references': 0.0}, {'affiliation.person_id': 'DavidKasal.1969', 'average_named_entity_references': 0.0}]

Running time 20.072021484375 ms

+--------------------------------+---------------------------------+
| affiliation.person_id | average_named_entity_references |
+--------------------------------+---------------------------------+
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[{'affiliation.role': 'member', 'average_sentence_count': 10.937954642704321}, {'affiliation.role': 'head', 'average_sentence_count': 11.042723631508679}, {'affiliation.role': 'deputyHead', 'average_sentence_count': 8.285714285714286}]

Running time 14.8916015625 ms

+------------------+------------------------+
| affiliation.role | average_sentence_count |
+------------------+------------------------+
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[{'speech.role': 'guest', 'average_tokens': 1077.8934426229507}, {'speech.role': 'regular', 'average_tokens': 496.90713671539123}, {'speech.role': 'chair', 'average_tokens': 143.19426456984274}]

Running time 7.8427734375 ms

+-------------+--------------------+
| speech.role | average_tokens |
+-------------+--------------------+
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[{'speech.earliest_timestamp': '12:48:00', 'average_wpm': 161.34031413612567}]

Running time 9.771728515625 ms

+---------------------------+--------------------+
| speech.earliest_timestamp | average_wpm |
+---------------------------+--------------------+
Expand Down
2 changes: 2 additions & 0 deletions test/API/examples/actual/fastest_speaking_speakers_result.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[{'speech.person_id': 'BronislavSchwarz.1966', 'average_wpm': 161.34031413612567}, {'speech.person_id': 'LukasKolarik.1984', 'average_wpm': 155.80850204389782}, {'speech.person_id': 'OndrejVesely.1976', 'average_wpm': 151.81583647549118}, {'speech.person_id': 'PavelBlazek.1969', 'average_wpm': 149.77964855666076}, {'speech.person_id': 'MilanChovanec.1970', 'average_wpm': 149.25437760129654}, {'speech.person_id': 'MarianJurecka.1981', 'average_wpm': 147.04994388205515}, {'speech.person_id': 'RobertPlaga.1978', 'average_wpm': 145.44581783271332}, {'speech.person_id': 'MarcelChladek', 'average_wpm': 145.00501169395255}, {'speech.person_id': 'MiloslavJanulik.1962', 'average_wpm': 143.10080192959902}, {'speech.person_id': 'MartinKolovratnik.1975', 'average_wpm': 142.27168366868392}]

Running time 8.635498046875 ms

+------------------------+--------------------+
| speech.person_id | average_wpm |
+------------------------+--------------------+
Expand Down
2 changes: 2 additions & 0 deletions test/API/examples/actual/gender_average_tokens_result.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[{'person.sex': '', 'average_tokens': 1335.3333333333333}, {'person.sex': 'M', 'average_tokens': 325.23359818388195}, {'person.sex': 'F', 'average_tokens': 245.54014029618082}]

Running time 5.929931640625 ms

+------------+--------------------+
| person.sex | average_tokens |
+------------+--------------------+
Expand Down
2 changes: 2 additions & 0 deletions test/API/examples/actual/gender_total_speeches_result.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[{'person.sex': '', 'total_speeches': 3}, {'person.sex': 'M', 'total_speeches': 4405}, {'person.sex': 'F', 'total_speeches': 1283}]

Running time 5.25048828125 ms

+------------+----------------+
| person.sex | total_speeches |
+------------+----------------+
Expand Down
2 changes: 2 additions & 0 deletions test/API/examples/actual/most_speeches_male_result.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[{'person.person_id': 'RadekVondracek.1973', 'total_speeches': 769}, {'person.person_id': 'JanHamacek.1978', 'total_speeches': 587}, {'person.person_id': 'TomioOkamura.1972', 'total_speeches': 303}, {'person.person_id': 'JanBartosek.1971', 'total_speeches': 287}, {'person.person_id': 'VojtechFilip.1955', 'total_speeches': 262}, {'person.person_id': 'MiroslavKalousek.1960', 'total_speeches': 160}, {'person.person_id': 'ZbynekStanjura.1964', 'total_speeches': 127}, {'person.person_id': 'PetrFiala.1964', 'total_speeches': 126}, {'person.person_id': 'JanSkopecek.1980', 'total_speeches': 119}, {'person.person_id': 'VojtechPikal.1987', 'total_speeches': 89}]

Running time 10.435791015625 ms

+-----------------------+----------------+
| person.person_id | total_speeches |
+-----------------------+----------------+
Expand Down
2 changes: 2 additions & 0 deletions test/API/examples/actual/most_talkative_regulars_result.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[{'persName.forename': 'Josef', 'persName.surname': 'Bělica', 'total_tokens': 307}, {'persName.forename': 'Alena', 'persName.surname': 'Gajdůšková', 'total_tokens': 65}, {'persName.forename': 'Antonín', 'persName.surname': 'Seďa', 'total_tokens': 117}, {'persName.forename': 'Věra', 'persName.surname': 'Adámková', 'total_tokens': 7310}, {'persName.forename': 'Vít', 'persName.surname': 'Vomáčka', 'total_tokens': 29}, {'persName.forename': 'Stanislav', 'persName.surname': 'Juránek', 'total_tokens': 89}, {'persName.forename': 'Robert', 'persName.surname': 'Stržínek', 'total_tokens': 653}, {'persName.forename': 'Petr', 'persName.surname': 'Třešňák', 'total_tokens': 227}, {'persName.forename': 'Jakub', 'persName.surname': 'Michálek', 'total_tokens': 11491}, {'persName.forename': 'Vladimíra', 'persName.surname': 'Lesenská', 'total_tokens': 1003}]

Running time 9.15185546875 ms

+-------------------+------------------+--------------+
| persName.forename | persName.surname | total_tokens |
+-------------------+------------------+--------------+
Expand Down
2 changes: 2 additions & 0 deletions test/API/examples/actual/politician_comparisonCS_result.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[{'person.person_id': 'AdamKalous.1979', 'persName.forename': 'Adam', 'persName.surname': 'Kalous', 'total_speeches': 0}, {'person.person_id': 'AdamRykala.1986', 'persName.forename': 'Adam', 'persName.surname': 'Rykala', 'total_speeches': 0}]

Running time 7.3037109375 ms

+------------------+-------------------+------------------+----------------+
| person.person_id | persName.forename | persName.surname | total_speeches |
+------------------+-------------------+------------------+----------------+
Expand Down
2 changes: 2 additions & 0 deletions test/API/examples/actual/speech_count_parties_result.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[{'organisation.name': 'Poslanecký klub Úsvit - Národní Koalice', 'total_speeches': 105}, {'organisation.name': 'Úsvit přímé demokracie Tomia Okamury', 'total_speeches': 114}, {'organisation.name': 'Poslanecký klub České pirátské strany', 'total_speeches': 294}, {'organisation.name': 'Poslanecký klub Komunistické strany Čech a Moravy', 'total_speeches': 468}, {'organisation.name': 'Svoboda a prima demokracie - Tomio Okamura', 'total_speeches': 29}, {'organisation.name': 'Křesťanská a demokratická unie - Československá strana lidová', 'total_speeches': 253}, {'organisation.name': 'Česká strana sociálně demokratická', 'total_speeches': 735}, {'organisation.name': 'Poslanecký klub Starostové a nezávislí', 'total_speeches': 293}, {'organisation.name': 'Poslanecký klub TOP 09 a Starostové', 'total_speeches': 415}, {'organisation.name': 'Poslanecký klub Svoboda a přímá demokracie', 'total_speeches': 161}, {'organisation.name': 'Česká pirátská strana', 'total_speeches': 227}, {'organisation.name': 'Poslanecký klub Občanské demokratické strany', 'total_speeches': 550}, {'organisation.name': 'Poslanecký klub TOP 09', 'total_speeches': 197}, {'organisation.name': 'Občanská demokratická strana', 'total_speeches': 367}, {'organisation.name': 'Poslanecký klub ANO 2011', 'total_speeches': 1101}, {'organisation.name': 'TOP 09', 'total_speeches': 392}, {'organisation.name': 'Poslanecký klub České strany sociálně demokratické', 'total_speeches': 1362}, {'organisation.name': 'Poslanecký klub KDU-ČSL', 'total_speeches': 353}, {'organisation.name': 'Starostove a nezavisli', 'total_speeches': 45}, {'organisation.name': 'ANO2011', 'total_speeches': 25}, {'organisation.name': 'Komunistická strana Čech a Moravy', 'total_speeches': 399}]

Running time 15.8046875 ms

+---------------------------------------------------------------+----------------+
| organisation.name | total_speeches |
+---------------------------------------------------------------+----------------+
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[{'affiliation.person_id': 'RadekVondracek.1973', 'total_duration_ms': 291840000.0}, {'affiliation.person_id': 'JaroslavaPokornaJermanova.1970', 'total_duration_ms': 137331790.0}, {'affiliation.person_id': 'AndrejBabis.1954', 'total_duration_ms': 95323344.0}, {'affiliation.person_id': 'JaroslavFaltynek.1962', 'total_duration_ms': 62572336.0}, {'affiliation.person_id': 'JanaMrackovaVildumetzova.1973', 'total_duration_ms': 39024576.0}, {'affiliation.person_id': 'AlenaSchillerova.1964', 'total_duration_ms': 27244690.0}, {'affiliation.person_id': 'KarelHavlicek.1969', 'total_duration_ms': 15647360.0}, {'affiliation.person_id': 'AdamVojtech.1986', 'total_duration_ms': 13979280.0}, {'affiliation.person_id': 'MartinKolovratnik.1975', 'total_duration_ms': 11743220.0}, {'affiliation.person_id': 'RichardBrabec.1966', 'total_duration_ms': 10657070.0}, {'affiliation.person_id': 'KlaraDostalova.1971', 'total_duration_ms': 8251750.0}, {'affiliation.person_id': 'HelenaValkova.1951', 'total_duration_ms': 4230210.0}, {'affiliation.person_id': 'JanVolny.1959', 'total_duration_ms': 3914380.0}, {'affiliation.person_id': 'JosefKott.1970', 'total_duration_ms': 3703800.0}, {'affiliation.person_id': 'DanTok.1959', 'total_duration_ms': 3655100.0}, {'affiliation.person_id': 'MartinStropnicky.1956', 'total_duration_ms': 3646530.0}, {'affiliation.person_id': 'VeraJourova.1964', 'total_duration_ms': 3494370.0}, {'affiliation.person_id': 'ZdenekSoukup.1952', 'total_duration_ms': 3380260.0}, {'affiliation.person_id': 'BronislavSchwarz.1966', 'total_duration_ms': 3342500.0}, {'affiliation.person_id': 'MarekNovak.1976', 'total_duration_ms': 3037740.0}, {'affiliation.person_id': 'JiriZlatuska.1957', 'total_duration_ms': 2756800.0}, {'affiliation.person_id': 'JiriBlaha.1961', 'total_duration_ms': 2298300.0}, {'affiliation.person_id': 'PatrikNacher.1974', 'total_duration_ms': 1891340.0}, {'affiliation.person_id': 'RobertPelikan.1979', 'total_duration_ms': 1476220.0}, {'affiliation.person_id': 'RadkaMaxova.1968', 'total_duration_ms': 1434500.0}, {'affiliation.person_id': 'MilanBrazdil.1962', 'total_duration_ms': 1387340.0}, {'affiliation.person_id': 'LubomirMetnar.1967', 'total_duration_ms': 1017200.0}, {'affiliation.person_id': 'MatejFichtner.1984', 'total_duration_ms': 917380.0}, {'affiliation.person_id': 'JosefHajek.1956', 'total_duration_ms': 893160.0}, {'affiliation.person_id': 'MiloslavJanulik.1962', 'total_duration_ms': 788900.0}, {'affiliation.person_id': 'RomanKubicek.1963', 'total_duration_ms': 732260.0}, {'affiliation.person_id': 'BerenikaPestova.1971', 'total_duration_ms': 478290.0}, {'affiliation.person_id': 'RobertKralicek.1977', 'total_duration_ms': 414070.0}, {'affiliation.person_id': 'PetrVrana.1975', 'total_duration_ms': 244040.0}, {'affiliation.person_id': 'DavidKasal.1969', 'total_duration_ms': 150220.0}, {'affiliation.person_id': 'OndrejBabka.1994', 'total_duration_ms': 108290.0}, {'affiliation.person_id': 'IvoVondrak.1959', 'total_duration_ms': 18300.0}, {'affiliation.person_id': 'JanaHanzlikova.1966', 'total_duration_ms': 0.0}, {'affiliation.person_id': 'JaroslavBzoch.1983', 'total_duration_ms': 0.0}]

Running time 20.956298828125 ms

+--------------------------------+-------------------+
| affiliation.person_id | total_duration_ms |
+--------------------------------+-------------------+
Expand Down
2 changes: 2 additions & 0 deletions test/API/examples/actual/total_sentences_female_result.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[{'person.sex': 'F', 'total_sentences': 18642}]

Running time 7.7900390625 ms

+------------+-----------------+
| person.sex | total_sentences |
+------------+-----------------+
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[{'organisation.role': 'interparliamentaryFriendshipGroup', 'COUNT(speech.id) as total_speeches': 17013}, {'organisation.role': 'committee', 'COUNT(speech.id) as total_speeches': 9380}, {'organisation.role': 'parliament', 'COUNT(speech.id) as total_speeches': 6220}, {'organisation.role': 'parliamentaryGroup', 'COUNT(speech.id) as total_speeches': 5299}, {'organisation.role': 'subcommittee', 'COUNT(speech.id) as total_speeches': 4803}, {'organisation.role': 'politicalParty', 'COUNT(speech.id) as total_speeches': 2586}, {'organisation.role': 'commission', 'COUNT(speech.id) as total_speeches': 1890}, {'organisation.role': 'delegation', 'COUNT(speech.id) as total_speeches': 1452}, {'organisation.role': 'government', 'COUNT(speech.id) as total_speeches': 383}, {'organisation.role': 'supervisoryBoard', 'COUNT(speech.id) as total_speeches': 201}, {'organisation.role': 'boardOfDirectors', 'COUNT(speech.id) as total_speeches': 14}, {'organisation.role': 'republic', 'COUNT(speech.id) as total_speeches': 4}]

Running time 35.09228515625 ms

+-----------------------------------+------------------------------------+
| organisation.role | COUNT(speech.id) as total_speeches |
+-----------------------------------+------------------------------------+
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[{'person.sex': 'M', 'total_speeches': 285}]

Running time 4.737060546875 ms

+------------+----------------+
| person.sex | total_speeches |
+------------+----------------+
Expand Down
Loading

0 comments on commit a016ac5

Please sign in to comment.