def run(self): # Print the maximum thread count print "MAX_THREAD_COUNT: " + str(self.MAX_THREAD_COUNT) # Create threads number = self.MAX_THREAD_COUNT - len(self.threads) print "Creating " + str(number) + " active threads" for i in xrange(number): # Start thread and add to list th = HTTPClient() th.start() self.threads.append(th) # Loop until interrupted by Ctrl + C while not self.kill_received: # Print current date and time and current thread count now = datetime.datetime.now() print "[Client:run] Current date and time:" + str(now) print "[Client:run] Current concurrent thread count:" + str(len(self.threads)) # Get & reset counters getsPerMinute = 0 postsPerMinute = 0 for th in self.threads: getsPerMinute += th.getReqs th.getReqs = 0 postsPerMinute += th.postReqs th.postReqs = 0 getsPerMinute = getsPerMinute / len(self.threads) postsPerMinute = postsPerMinute / len(self.threads) print "[Client:run] Operating at " + str(getsPerMinute) + " GET/m and " + str(postsPerMinute) + " POST/m" # Repeat for bandwidth rxBytes = 0 txBytes = 0 for th in self.threads: rxBytes += th.rxBytes th.rxBytes = 0 txBytes += th.txBytes th.txBytes = 0 rxBytes = rxBytes / len(self.threads) txBytes = txBytes / len(self.threads) # rxBytes = rxBytes / 1000000 # txBytes = txBytes / 1000000 print "[Client:run] Downloading at " + str(rxBytes) + " B/m and Uploading at " + str(txBytes) + " B/m" # Have a snooze... time.sleep(60)