test.py 1.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# Copyright 2014 Budapest University of Technology and Economics (BME IK)
#
# This file is part of CIRCLE Cloud.
#
# CIRCLE is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# CIRCLE is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with CIRCLE.  If not, see <http://www.gnu.org/licenses/>.

Őry Máté committed
18
from calvin import *  # noqa
Nagy Gergő committed
19 20 21 22 23 24 25 26
import datetime

query = Query()
query.setTarget("2008.vm.ik.bme.hu.circle")
query.setMetric("cpu.usage")
query.setAbsoluteStart("2013", "10", "23", "00", "00")
query.generate()

Nagy Gergő committed
27
handler = GraphiteHandler("10.9.1.209")
Nagy Gergő committed
28

Őry Máté committed
29 30
times = int(input(
    "How many requests do you intend to send? [postive integer]  "))
Nagy Gergő committed
31 32

global_start = datetime.datetime.now()
Nagy Gergő committed
33
for i in range(1, times):
Nagy Gergő committed
34 35 36 37
    local_start = datetime.datetime.now()
    handler.put(query)
    handler.send()
    local_end = datetime.datetime.now()
Őry Máté committed
38
    print((local_end - local_start).microseconds)
Nagy Gergő committed
39 40 41 42 43 44
global_end = datetime.datetime.now()

print("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*")
print("Summary:")
print(global_end - global_start)
print("AVG:")
Nagy Gergő committed
45
print((global_end - global_start) / times)
Nagy Gergő committed
46
print("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*")