benchmark_config.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. from toolset.benchmark.test_types import *
  2. from toolset.utils.output_helper import QuietOutputStream
  3. import os
  4. import time
  5. class BenchmarkConfig:
  6. def __init__(self, args):
  7. '''
  8. Configures this BenchmarkConfig given the arguments provided.
  9. '''
  10. # Map type strings to their objects
  11. types = dict()
  12. types['json'] = JsonTestType(self)
  13. types['db'] = DBTestType(self)
  14. types['query'] = QueryTestType(self)
  15. types['fortune'] = FortuneTestType(self)
  16. types['update'] = UpdateTestType(self)
  17. types['plaintext'] = PlaintextTestType(self)
  18. types['cached_query'] = CachedQueryTestType(self)
  19. # Turn type into a map instead of a string
  20. if args['type'] == 'all':
  21. args['types'] = types
  22. else:
  23. args['types'] = {args['type']: types[args['type']]}
  24. del args['type']
  25. args['max_concurrency'] = max(args['concurrency_levels'])
  26. if 'pipeline_concurrency_levels' not in args:
  27. args['pipeline_concurrency_levels'] = [256, 1024, 4096, 16384]
  28. self.quiet = False
  29. self.client_user = ""
  30. self.client_host = ""
  31. self.client_identity_file = ""
  32. self.database_user = ""
  33. self.database_host = ""
  34. self.database_identity_file = ""
  35. self.parse = False
  36. self.new = False
  37. self.init = False
  38. self.build = False
  39. self.clean = False
  40. self.list_tests = False
  41. self.concurrency_levels = []
  42. self.pipeline_concurrency_levels = []
  43. self.__dict__.update(args)
  44. self.quiet_out = QuietOutputStream(self.quiet)
  45. self.start_time = time.time()
  46. # setup some additional variables
  47. if self.database_user == None: self.database_user = self.client_user
  48. if self.database_host == None: self.database_host = self.client_host
  49. if self.database_identity_file == None:
  50. self.database_identity_file = self.client_identity_file
  51. # Remember root directory
  52. self.fwroot = os.getenv('FWROOT')
  53. if hasattr(self, 'parse') and self.parse != None:
  54. self.timestamp = self.parse
  55. else:
  56. self.timestamp = time.strftime("%Y%m%d%H%M%S", time.localtime())
  57. # Setup the ssh commands
  58. self.client_ssh_command = [
  59. 'ssh', '-T', '-o', 'StrictHostKeyChecking=no',
  60. self.client_user + "@" + self.client_host
  61. ]
  62. if self.client_identity_file != None:
  63. self.client_ssh_command.extend(['-i', self.client_identity_file])
  64. self.database_ssh_command = [
  65. 'ssh', '-T', '-o', 'StrictHostKeyChecking=no',
  66. self.database_user + "@" + self.database_host
  67. ]
  68. if self.database_identity_file != None:
  69. self.database_ssh_command.extend(
  70. ['-i', self.database_identity_file])
  71. self.run_test_timeout_seconds = 7200