1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
# -*- coding: utf-8 -*-
from datetime import datetime, timezone
import json
import os
import pprint
from pyutils import env, log, runtools
def _git_commit():
from pyutils import buildinfo
return runtools.run(['git', 'rev-parse', 'HEAD'],
cwd=buildinfo.source_dir).strip()
def _git_datetime():
from pyutils import buildinfo
posixtime = runtools.run(
['git', 'show', '-s', '--format=%ct',
_git_commit()],
cwd=buildinfo.source_dir)
return datetime.fromtimestamp(int(posixtime), timezone.utc).isoformat()
def _now():
return datetime.now(timezone.utc).astimezone().isoformat()
def run(domain, runs):
from pyutils import buildinfo
binary = os.path.join(buildinfo.binary_dir, 'tests', 'regression',
'perftests')
output = runtools.srun([binary] + [str(d)
for d in domain] + [str(runs), '-d'])
data = json.loads(output)
data['gridtools'] = {'commit': _git_commit(), 'datetime': _git_datetime()}
data['environment'] = {
'hostname': env.hostname(),
'clustername': env.clustername(),
'compiler': buildinfo.compiler,
'datetime': _now(),
'envfile': buildinfo.envfile
}
data['domain'] = list(domain)
log.debug('Perftests data', pprint.pformat(data))
return data
|