def benchmarkProfile(context, scenario): """ Create a benchmark for an application """ with TargetLauncher(context, scenario) as app: report = generateProfiles(app.xpediteApp, scenario, context) makeBenchmark(report.profiles, scenario.dataDir) benchmarkAppInfoPath = os.path.join(scenario.dataDir, BENCHMARK_APP_INFO_PATH) replaceWorkspace(benchmarkAppInfoPath, context.workspace, benchmarkAppInfoPath)
def makeBenchmark(self, path): """ Persists samples for current run in the given path for future benchmarking :param path: Path to persist profiles for the current session """ from xpedite import benchmark return benchmark.makeBenchmark(self, path)
def generateBaseline(binary, tempDir, workspace, appName): """ Generate the following files: 1. .xpd data file generated from building a Jupyter notebook Used to test building of notebooks 2. Xpedite application information file Used to attach profiler for testing recording, reporting, probe status, and notebooks 3. xpediteDemo .data files Files that are collected by an xpedite app to build transactions 4. Serialized probe baseline file Used to compare probe states generated by an xpedite app to baseline probes """ import json import tempfile import cPickle as pickle from xpedite.benchmark import makeBenchmark txnCount = 1000 threadCount = 1 tempDir = os.path.join(tempDir, appName) cleanUpDataDir(tempDir, appName) _, dataFilePath, app, result = buildNotebook(tempDir, binary, txnCount, threadCount, workspace=workspace) replaceWorkspace(app.xpediteApp.appInfoPath, workspace, os.path.join(tempDir, 'xpedite-appinfo.txt')) copy(dataFilePath, os.path.join(tempDir, 'reportCmdBaseline.xpd')) fullCpuInfo = app.xpediteApp.env.proxy.fullCpuInfo baselineCpuInfoPath = os.path.join(tempDir, 'baselineCpuInfo.json') with open(baselineCpuInfoPath, 'w') as fileHandle: json.dump(fullCpuInfo, fileHandle) for dataFile in app.xpediteApp.gatherFiles( app.xpediteApp.sampleFilePattern()): copy(dataFile, os.path.join(tempDir, os.path.basename(dataFile))) makeBenchmark(result.profiles, os.path.join(tempDir, 'benchmark')) benchmarkAppInfo = os.path.join(tempDir, 'benchmark/benchmark/appinfo.txt') replaceWorkspace(benchmarkAppInfo, workspace, benchmarkAppInfo) benchmarkProfilePath = os.path.join(tempDir, 'profileInfoWithBenchmark.py') _, benchmarkDataFilePath, _, _ = buildNotebook( tempDir, binary, txnCount, threadCount, profileInfoPath=benchmarkProfilePath, runId=app.xpediteApp.runId, workspace=workspace) copy(benchmarkDataFilePath, os.path.join(tempDir, 'reportCmdBaselineWithBenchmark.xpd')) profileInfo = loadProfileInfo(tempDir, os.path.join(tempDir, 'profileInfo.py')) probes = loadProbes(binary, profileInfo, txnCount, threadCount, workspace=workspace) with open(os.path.join(tempDir, 'probeCmdBaseline.pkl'), 'wb') as probeFileHandle: probeFileHandle.write(pickle.dumps(probes))