Skip to content

Instantly share code, notes, and snippets.

@tsuna
Created February 27, 2011 09:29
Show Gist options
  • Save tsuna/846049 to your computer and use it in GitHub Desktop.
Save tsuna/846049 to your computer and use it in GitHub Desktop.
Quick script to run a couple queries against a TSD and time it
#!/usr/bin/python
import httplib
import json
import os
import shutil
import time
def purge_tsd_cache():
for dir in (dir for dir in os.listdir("/tmp/tsd") if dir[0] != "."):
shutil.rmtree("/tmp/tsd/" + dir)
purge_tsd_cache()
metrics = ("ad1", "ad3")
tsd = httplib.HTTPConnection("127.0.0.1:4242")
tsd.connect()
def test(metric):
t = int(time.time() * 1000)
req = tsd.request("GET", "/q?start=2011/02/01-00:00:00&m=sum:%s&json" % metric)
resp = tsd.getresponse().read()
t = int(time.time() * 1000) - t
resp = json.loads(resp)
print ("%7d %s points, server reported latency = %dms, our client latency = %dms"
% (resp["points"], metric, resp["timing"], t))
return t
print "-- warm up --"
for metric in metrics:
test(metric)
print "-- test --"
timings = dict((metric, 0) for metric in metrics)
iterations = 5
for metric in metrics:
for i in xrange(iterations):
purge_tsd_cache()
timings[metric] += test(metric)
for metric in metrics:
print ("Average for %s out of %d runs: %dms"
% (metric, iterations, timings[metric] / iterations))
tsd.close()
@tsuna
Copy link
Author

tsuna commented Feb 27, 2011

tsuna@hactar ~/src/t $ for i in 16 32 64 128 256 512 1024; do
gsed -i "s/DEFAULT_MAX_NUM_ROWS = [0-9]*;/DEFAULT_MAX_NUM_ROWS = $i;/" ~/src/asynchbase/src/Scanner.java \
&& make -C ~/src/asynchbase &>/dev/null \
&& (cd ~/src/tsdb && \cp ~/src/asynchbase/build/hbaseasync-1.0.jar third_party/hbase \
    && ./src/tsdb tsd --port=4242 --staticroot=build/staticroot --cachedir=/tmp/tsd &>>/tmp/log) &
while :; do nc -z localhost 4242 >/dev/null && break; sleep 1; done \
&& echo "DEFAULT_MAX_NUM_ROWS = $i" && ./tsdq.py && echo diediedie | nc localhost 4242;
done

[3] 4461
DEFAULT_MAX_NUM_ROWS = 16
-- warm up --
956255 ad1 points, server reported latency = 12924ms, our client latency = 12947ms
1052822 ad3 points, server reported latency = 4497ms, our client latency = 4499ms
-- test --
956255 ad1 points, server reported latency = 10114ms, our client latency = 10116ms
956255 ad1 points, server reported latency = 9857ms, our client latency = 9859ms
956255 ad1 points, server reported latency = 9971ms, our client latency = 9973ms
956255 ad1 points, server reported latency = 10309ms, our client latency = 10311ms
956255 ad1 points, server reported latency = 9995ms, our client latency = 9996ms
1052822 ad3 points, server reported latency = 4189ms, our client latency = 4191ms
1052822 ad3 points, server reported latency = 4146ms, our client latency = 4148ms
1052822 ad3 points, server reported latency = 4134ms, our client latency = 4135ms
1052822 ad3 points, server reported latency = 4219ms, our client latency = 4221ms
1052822 ad3 points, server reported latency = 4266ms, our client latency = 4269ms
Average for ad1 out of 5 runs: 10051ms
Average for ad3 out of 5 runs: 4192ms
Cleaning up and exiting now.
[3] done (; cd ~/src/tsdb && \cp ~/src/asynchbase/build/hbaseasync-1.0.jar && tsd )
[3] 4498
DEFAULT_MAX_NUM_ROWS = 32
-- warm up --
956255 ad1 points, server reported latency = 12037ms, our client latency = 12057ms
1052822 ad3 points, server reported latency = 3730ms, our client latency = 3734ms
-- test --
956255 ad1 points, server reported latency = 8647ms, our client latency = 8669ms
956255 ad1 points, server reported latency = 8385ms, our client latency = 8387ms
956255 ad1 points, server reported latency = 8455ms, our client latency = 8458ms
956255 ad1 points, server reported latency = 8412ms, our client latency = 8413ms
956255 ad1 points, server reported latency = 8619ms, our client latency = 8621ms
1052822 ad3 points, server reported latency = 3454ms, our client latency = 3456ms
1052822 ad3 points, server reported latency = 3316ms, our client latency = 3317ms
1052822 ad3 points, server reported latency = 3318ms, our client latency = 3320ms
1052822 ad3 points, server reported latency = 3503ms, our client latency = 3505ms
1052822 ad3 points, server reported latency = 3288ms, our client latency = 3290ms
Average for ad1 out of 5 runs: 8509ms
Average for ad3 out of 5 runs: 3377ms
Cleaning up and exiting now.
[3] done (; cd ~/src/tsdb && \cp ~/src/asynchbase/build/hbaseasync-1.0.jar && tsd )
[3] 4536
DEFAULT_MAX_NUM_ROWS = 64
-- warm up --
956255 ad1 points, server reported latency = 10899ms, our client latency = 10918ms
1052822 ad3 points, server reported latency = 3312ms, our client latency = 3314ms
-- test --
956255 ad1 points, server reported latency = 7412ms, our client latency = 7414ms
956255 ad1 points, server reported latency = 7508ms, our client latency = 7895ms
956255 ad1 points, server reported latency = 8037ms, our client latency = 8039ms
956255 ad1 points, server reported latency = 8017ms, our client latency = 8020ms
956255 ad1 points, server reported latency = 7759ms, our client latency = 7761ms
1052822 ad3 points, server reported latency = 2951ms, our client latency = 2953ms
1052822 ad3 points, server reported latency = 2893ms, our client latency = 2895ms
1052822 ad3 points, server reported latency = 2900ms, our client latency = 2902ms
1052822 ad3 points, server reported latency = 3099ms, our client latency = 3102ms
1052822 ad3 points, server reported latency = 2858ms, our client latency = 2859ms
Average for ad1 out of 5 runs: 7825ms
Average for ad3 out of 5 runs: 2942ms
Cleaning up and exiting now.
[3] done (; cd ~/src/tsdb && \cp ~/src/asynchbase/build/hbaseasync-1.0.jar && tsd )
[3] 4574
DEFAULT_MAX_NUM_ROWS = 128
-- warm up --
956255 ad1 points, server reported latency = 10412ms, our client latency = 10431ms
1052822 ad3 points, server reported latency = 3136ms, our client latency = 3137ms
-- test --
956255 ad1 points, server reported latency = 7046ms, our client latency = 7067ms
956255 ad1 points, server reported latency = 7135ms, our client latency = 7138ms
956255 ad1 points, server reported latency = 7549ms, our client latency = 7550ms
956255 ad1 points, server reported latency = 7234ms, our client latency = 7236ms
956255 ad1 points, server reported latency = 7198ms, our client latency = 7201ms
1052822 ad3 points, server reported latency = 2786ms, our client latency = 2788ms
1052822 ad3 points, server reported latency = 2787ms, our client latency = 2790ms
1052822 ad3 points, server reported latency = 2935ms, our client latency = 2937ms
1052822 ad3 points, server reported latency = 2764ms, our client latency = 2766ms
1052822 ad3 points, server reported latency = 2808ms, our client latency = 2811ms
Average for ad1 out of 5 runs: 7238ms
Average for ad3 out of 5 runs: 2818ms
Cleaning up and exiting now.
[3] done (; cd ~/src/tsdb && \cp ~/src/asynchbase/build/hbaseasync-1.0.jar && tsd )
[3] 4610
DEFAULT_MAX_NUM_ROWS = 256
-- warm up --
956255 ad1 points, server reported latency = 10630ms, our client latency = 10648ms
1052822 ad3 points, server reported latency = 3226ms, our client latency = 3227ms
-- test --
956255 ad1 points, server reported latency = 7685ms, our client latency = 7711ms
956255 ad1 points, server reported latency = 7035ms, our client latency = 7036ms
956255 ad1 points, server reported latency = 6969ms, our client latency = 6970ms
956255 ad1 points, server reported latency = 6938ms, our client latency = 6940ms
956255 ad1 points, server reported latency = 7148ms, our client latency = 7150ms
1052822 ad3 points, server reported latency = 3532ms, our client latency = 3536ms
1052822 ad3 points, server reported latency = 2919ms, our client latency = 2920ms
1052822 ad3 points, server reported latency = 3510ms, our client latency = 3512ms
1052822 ad3 points, server reported latency = 3048ms, our client latency = 3049ms
1052822 ad3 points, server reported latency = 2924ms, our client latency = 2926ms
Average for ad1 out of 5 runs: 7161ms
Average for ad3 out of 5 runs: 3188ms
Cleaning up and exiting now.
[3] done (; cd ~/src/tsdb && \cp ~/src/asynchbase/build/hbaseasync-1.0.jar && tsd )
[3] 4646
DEFAULT_MAX_NUM_ROWS = 512
-- warm up --
956255 ad1 points, server reported latency = 10673ms, our client latency = 10691ms
1052822 ad3 points, server reported latency = 3335ms, our client latency = 3337ms
-- test --
956255 ad1 points, server reported latency = 7372ms, our client latency = 7374ms
956255 ad1 points, server reported latency = 7202ms, our client latency = 7204ms
956255 ad1 points, server reported latency = 7182ms, our client latency = 7278ms
956255 ad1 points, server reported latency = 7211ms, our client latency = 7213ms
956255 ad1 points, server reported latency = 7340ms, our client latency = 7342ms
1052822 ad3 points, server reported latency = 2848ms, our client latency = 2850ms
1052822 ad3 points, server reported latency = 2737ms, our client latency = 2739ms
1052822 ad3 points, server reported latency = 3033ms, our client latency = 3035ms
1052822 ad3 points, server reported latency = 2758ms, our client latency = 2759ms
1052822 ad3 points, server reported latency = 2833ms, our client latency = 2836ms
Average for ad1 out of 5 runs: 7282ms
Average for ad3 out of 5 runs: 2843ms
Cleaning up and exiting now.
[3] done (; cd ~/src/tsdb && \cp ~/src/asynchbase/build/hbaseasync-1.0.jar && tsd )
[3] 4684
DEFAULT_MAX_NUM_ROWS = 1024
-- warm up --
956255 ad1 points, server reported latency = 10638ms, our client latency = 10658ms
1052822 ad3 points, server reported latency = 4077ms, our client latency = 4082ms
-- test --
956255 ad1 points, server reported latency = 8065ms, our client latency = 8067ms
956255 ad1 points, server reported latency = 7193ms, our client latency = 7195ms
956255 ad1 points, server reported latency = 7282ms, our client latency = 7310ms
956255 ad1 points, server reported latency = 7349ms, our client latency = 7351ms
956255 ad1 points, server reported latency = 7573ms, our client latency = 7575ms
1052822 ad3 points, server reported latency = 2937ms, our client latency = 2939ms
1052822 ad3 points, server reported latency = 2728ms, our client latency = 2729ms
1052822 ad3 points, server reported latency = 2861ms, our client latency = 2864ms
1052822 ad3 points, server reported latency = 3239ms, our client latency = 3241ms
1052822 ad3 points, server reported latency = 2868ms, our client latency = 2870ms
Average for ad1 out of 5 runs: 7499ms
Average for ad3 out of 5 runs: 2928ms
Cleaning up and exiting now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment