Last active
August 8, 2019 07:44
-
-
Save peterjpxie/bdc7ebc8ab6124903207645efbfebba2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import threading | |
import queue | |
import sys | |
import time | |
# Global variables | |
queue_results = queue.Queue() | |
start_time = 0 | |
# def test_mock_service(): - omitted | |
# def loop_test(loop_wait=0, loop_times=sys.maxsize): - omitted | |
if __name__ == '__main__': | |
### Test Settings ### | |
concurrent_users = 2 | |
loop_times = 3 | |
workers = [] | |
start_time = time.time() | |
print('Tests started at %s.' % start_time ) | |
# start concurrent user threads | |
for i in range(concurrent_users): | |
thread = threading.Thread(target=loop_test, kwargs={'loop_times': loop_times}, daemon=True) | |
thread.start() | |
workers.append(thread) | |
# Block until all threads finish. | |
for w in workers: | |
w.join() | |
end_time = time.time() | |
print('\nTests ended at %s.' % end_time ) | |
print('Total test time: %s seconds.' % (end_time - start_time) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment