Permalink
Browse files

Made agent publish truncated timestamps

  • Loading branch information...
1 parent 20ede5d commit 75686de2fa1c589c4b23d8cb5d8c521be711dfbd Bogdan Gaza committed Jun 18, 2012
Showing with 9 additions and 3 deletions.
  1. +2 −1 kali-agent/agent.py
  2. +7 −2 kali-agent/kali-agent-benchmark.py
View
@@ -2,6 +2,7 @@
import zmq
import re
import time
+import math
from msgpack import packb
@@ -66,7 +67,7 @@ def store_metric(self,message):
self.lock.acquire()
if bucket not in self.metrics:
self.metrics[bucket] = []
- self.metrics[bucket].append({ 'v' : float(value), 't': time.time() })
+ self.metrics[bucket].append({ 'v' : float(value), 't': math.trunc(time.time()) })
finally:
self.lock.release()
@@ -8,11 +8,15 @@
context = zmq.Context()
socket = context.socket(zmq.REQ)
+semaphore = threading.BoundedSemaphore(50)
+
def run():
+ semaphore.acquire()
+
socket = context.socket(zmq.REQ)
socket.connect("ipc:///tmp/local.pipe")
- N = 3
+ N = 1000
loop_start = time.time()
bucket = ""
@@ -32,9 +36,10 @@ def run():
print x
print float(N) / x
+ semaphore.release()
threads = []
-for i in range(10):
+for i in range(1):
t = threading.Thread(target=run)
t.start()

0 comments on commit 75686de

Please sign in to comment.