import os import logging from locust import Locust, events, task, TaskSet import RepoBenchmark import RepoLocust logger = logging.getLogger("repo_benchmark") startdir = os.getcwd() class P4RepoTasks(TaskSet): min_wait = 1000 max_wait = 10000 request_type = "p4" def __init__(self, *args, **kwargs): super(P4RepoTasks, self).__init__(*args, **kwargs) self.config = RepoBenchmark.readConfig(startdir) self.min_wait = self.config["general"]["min_wait"] self.max_wait = self.config["general"]["max_wait"] def on_start(self): name = "sync" count = 0 t = RepoLocust.Timer(self.request_type) try: self.rb = RepoBenchmark.P4Benchmark(startdir, self.config) existed = self.rb.createWorkspace() if not existed: name = "init_sync" count = self.rb.syncWorkspace() except Exception as e: logger.exception(e) t.report_failure(name, e) else: t.report_success(name, count) @task(10) def basicFileActions(self): pass # RepoBenchmark.basicFileActions(self.rb, self.request_type) class P4RepoTestLocust(Locust): """Will be imported and then run by locust""" task_set = P4RepoTasks
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 24727 | Robert Cowham | Refactored | ||
#1 | 24711 | Robert Cowham | Restructure and tidy up | ||
//guest/robert_cowham/p4benchmark/main/p4_locust.py | |||||
#5 | 19799 | Robert Cowham | Refactored to put some common stuff in RepoLocust.py | ||
#4 | 19798 | Robert Cowham |
Log exceptions. Refactor Svn as well |
||
#3 | 19797 | Robert Cowham | Refactored timing | ||
#2 | 19796 | Robert Cowham | Refactored into taskset | ||
#1 | 19773 | Robert Cowham | Initial version of benchmark scripts |