-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdb_performance_test.py
More file actions
32 lines (28 loc) · 923 Bytes
/
db_performance_test.py
File metadata and controls
32 lines (28 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from db_functions import db_main, db_trip
import time
from threading import Timer
from datetime import datetime
import os
TIME = 3600
REPEAT = 24
def test():
program_start = datetime.now()
print "test started at: %s" %program_start.strftime("%Y-%m-%d %H:%M:%S")
# Connect to the database
db_main.connect("db_functions/database.conf")
trips = db_trip.find_pickup_dt('2010-01-01 00:34:00', '2010-01-01 12:34:00')
run_time = datetime.now() - program_start
print run_time
print len(trips)
def system():
program_start = datetime.now()
print "system status at: %s" %program_start.strftime("%Y-%m-%d %H:%M:%S")
print os.system("ps -eo %cpu,%mem,pid,user,comm| sort -r | head -15")
print "performance test started at: %s" %datetime.now().strftime("%Y-%m-%d %H:%M:%S")
for t in range(REPEAT):
Timer(t*TIME, test).start()
Timer(t*TIME+10, system).start()
#one hour worths of trip
#duration
#number of trips
#ram&cpu