Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
energy
bmon
Commits
efbc7808
Commit
efbc7808
authored
Feb 05, 2015
by
Alan Mitchell
Browse files
Added Performance Testing script
parent
cbc6a82e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
+56
-0
bmsapp/scripts/performance_testing.py
bmsapp/scripts/performance_testing.py
+56
-0
No files found.
bmsapp/scripts/performance_testing.py
0 → 100644
View file @
efbc7808
#!/usr/local/bin/python2.7
""" Script to test the performance of the BMON server under various load conditions
"""
import
threading
import
time
import
random
import
json
import
yaml
import
requests
req_data
=
yaml
.
load
(
'''
select_group: 0
select_bldg: 1
select_chart: 2
select_sensor: [2, 3, 4]
averaging_time: 720
time_period: custom
start_date: 01/01/2014
end_date: 12/31/2014 # Getting one year of data
'''
)
def
results_time
():
'''Determine average time to complete a report request.
This returns a tuple: (average completion time in seconds,
average 1 minute load,
average 5 minute load,
average 15 minute load,
average reading database size in bytes)
'''
TRIES
=
5
tc
=
0.0
load01
=
0.0
load05
=
0.0
load15
=
0.0
dbsize
=
0.0
for
i
in
range
(
TRIES
):
tstart
=
time
.
time
()
# Add a random parameter to avoid caching, although probably not needed
req_data
[
'rdm'
]
=
random
.
random
()
r
=
requests
.
get
(
"https://bmon.ahfctest.webfactional.com/reports/results/"
,
params
=
req_data
,
verify
=
False
)
tcomplete
=
time
.
time
()
-
tstart
res
=
json
.
loads
(
r
.
text
)
stats
=
res
[
'objects'
][
-
1
][
1
]
tc
+=
tcomplete
load01
+=
stats
[
'loads'
][
0
]
load05
+=
stats
[
'loads'
][
1
]
load15
+=
stats
[
'loads'
][
2
]
dbsize
+=
stats
[
'dbsize'
]
return
tc
/
TRIES
,
load01
/
TRIES
,
load05
/
TRIES
,
load15
/
TRIES
,
dbsize
/
TRIES
if
__name__
==
'__main__'
:
print
results_time
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment