15 import conbench.runner
29 powers = {
's': 0,
'ms': 3,
'us': 6,
'ns': 9 }
30 return 10 ** (powers[time_unit_to] - powers[time_unit_from])
34 '''Run google benchmarks and publish them to the network conbench server.'''
37 description =
'Google Benchmark'
41 for benchmark
in benchmarks:
42 if 'aggregate_name' not in benchmark:
43 aggregate = aggregates.get(benchmark[
'name'])
45 aggregates[benchmark[
'name']] = {
46 'data': [ benchmark[
'real_time'] ],
47 'unit': benchmark[
'time_unit'] }
49 conversion_factor =
conversionFactor(aggregate[
'unit'], benchmark[
'time_unit'])
50 aggregate[
'data'].
append(conversion_factor * benchmark[
'real_time'])
53 def run(self, name, kwargs):
54 context = {
'benchmark_language':
'C++' }
55 commit = os.environ.get(
'GIT_COMMIT')
56 build_dir =
'../../build-{0}'.format(commit)
57 benchmark_out =
'{0}/{1}-{2}.json'.format(os.getcwd(), name, commit)
59 command = [
'./'+name,
'--benchmark_repetitions=7',
'--benchmark_out='+benchmark_out]
60 subprocess.run(command, cwd=build_dir+
'/Tests')
62 report = json.load(
open(benchmark_out))
63 info = report[
'context']
64 info[
'branch'] = os.environ.get(
'GIT_BRANCH')
69 for benchmark_name, result
in aggregates.items():
71 tags = {
'benchmark_name': benchmark_name }
72 yield self.conbench.record(
73 result, name, context=context, options=options, output=result, tags=tags, info=info
77 def __init__(self, bindir, datadir, port_main, port_http, port_calcite):
79 self.
heavydb = subprocess.Popen([bindir+
'/heavydb',
'--allowed-import-paths=["/"]',
80 '--allowed-export-paths=["/"]',
'--enable-http-binary-server=0',
'--port='+str(port_main),
81 '--http-port='+str(port_http),
'--calcite-port='+str(port_calcite), datadir])
82 print(
'heavydb server started pid='+str(self.heavydb.pid))
84 print(
'Shutting down heavydb server.')
85 self.heavydb.terminate()
86 print(
'Server return value=%d' % (self.heavydb.wait()))
88 if not os.path.isdir(datadir):
89 os.mkdir(datadir, mode=0o775)
90 initheavy = subprocess.run([bindir+
'/initheavy', datadir])
91 assert initheavy.returncode == 0,
'initheavy returned {0}.'.format(initheavy)
95 query = b
'SELECT COUNT(*) FROM heavyai_us_states;'
96 print(
'Running test query: %s' % (query))
97 FAILED_TO_OPEN_TRANSPORT = b
'Failed to open transport. Is heavydb running?'
98 stdout = FAILED_TO_OPEN_TRANSPORT
101 while stdout.startswith(FAILED_TO_OPEN_TRANSPORT):
104 print(
'Connection attempt {0}'.format(attempts))
106 print(
'Too many failed connection attempts. Returning -1.')
108 heavysql = subprocess.Popen([bindir+
'/heavysql',
'-p',
'HyperInteractive',
'--port', str(port_main),
109 '--quiet'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
110 (stdout, stderr) = heavysql.communicate(query)
115 assert number_of_us_states
in range(13,100),
'Incorrect number of US states(%d)' % (number_of_us_states)
116 print(
'Counted %d rows in table heavyai_us_states.' % (number_of_us_states))
118 @conbench.runner.register_benchmark
122 yield from GoogleBenchmark.run(self, self.
name, kwargs)
124 @conbench.runner.register_benchmark
126 '''TPC-DS SQL tests'''
130 description =
'TPC-DS SCALE=%s SQL tests' % (SCALE)
133 BASENAME=
'TPC-DS_Tools_v3.2.0'
134 OUTPUT_DIR=
'%s_%sGB' % (BASENAME, SCALE)
135 PG_TGZ=OUTPUT_DIR +
'.tgz'
140 SENTINEL_FAILED_TIME=1234567.890
143 assets_dir = os.environ.get(
'TPCDS_ASSETS_DIR')
144 assert assets_dir !=
None,
'Please set env variable TPCDS_ASSETS_DIR to directory with %s.' % (self.
PG_TGZ)
146 assert os.path.exists(
'%s/.conbench' % os.environ.get(
'HOME')
147 ),
'A .conbench file is required to submit results to a conbench server.'
148 assert os.path.exists(
'%s/%s' % (assets_dir, file)),
'File %s not found in %s.' % (file, assets_dir)
153 os.mkdir(workingdir, mode=0o775)
154 rakefile = os.path.realpath(os.path.join(os.getcwd(),
'../rake/Rakefile'))
155 subprocess.run([
'ln',
'-s', rakefile, workingdir])
158 subprocess.run([
'tar',
'zxf',
'%s/%s'%(assets_dir,self.
PG_TGZ)])
161 commit = os.environ.get(
'GIT_COMMIT')
162 build_dir = os.path.realpath(os.path.join(os.getcwd(),
'../../build-%s'%(commit)))
165 bindir = build_dir +
'/bin'
169 env = {
'HEAVYSQL':
'%s/heavysql -p HyperInteractive --port %d'%(bindir,self.
PORT_MAIN)
170 ,
'SCALE': self.
SCALE,
'SKIP_PG':
'1',
'PATH': os.environ.get(
'PATH') }
171 subprocess.run(
'rake tpcds:compare', env=env, shell=
True)
173 context = {
'benchmark_language':
'C++' }
174 info = {
'branch': os.environ.get(
'GIT_BRANCH') }
177 def query_num(filename):
178 md = re.search(
'/query(\d+).json$', filename)
179 return int(md.group(1))
if md
else 0
180 for filename
in sorted(glob.glob(self.
OUTPUT_DIR+
'/query*.json'), key=query_num):
181 with
open(filename)
as file:
182 benchmark = json.load(file)
183 tags = {
'benchmark_name':
'%02d' % query_num(filename) }
185 result = {
'data': data,
'unit':
'ms' }
186 info[
'message'] = benchmark[
'message'][:4096]
187 yield self.conbench.record(
188 result, self.
name, context=context, options=options, output=result, tags=tags, info=info
size_t append(FILE *f, const size_t size, const int8_t *buf)
Appends the specified number of bytes to the end of the file f from buf.
def checkForRequiredFiles
int open(const char *path, int flags, int mode)
def setupAndChdirToWorkingDirectory
float SENTINEL_FAILED_TIME