forked from ABHISHIKTH5C0/bidnamic-data-challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.py
22 lines (18 loc) · 880 Bytes
/
profile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import timeit
import psycopg2
from main import conn_options, ingest, aggregate_roas
def ingest_all(conn):
ingest(conn, 'campaigns.csv', 'campaigns')
ingest(conn, 'adgroups.csv', 'adgroups')
ingest(conn, 'search_terms.csv', 'search_terms')
def profile():
with psycopg2.connect(**conn_options) as conn:
number_of_calls = 100
time_to_execute = timeit.timeit(lambda: ingest_all(conn), number=number_of_calls)
print("Average time taken to ingest()", time_to_execute / number_of_calls, " seconds.")
with conn.cursor() as cur:
number_of_calls = 100
time_to_execute = timeit.timeit(lambda: aggregate_roas(cur, by=['country', 'priority']), number=number_of_calls)
print("Average time taken to aggregate_roas():", time_to_execute / number_of_calls, " seconds.")
if __name__ == '__main__':
profile()