def test_notebook_build(capsys): """ Test to confirm a Jupyter notebook can be creating from profile information and results generated by xpedite record """ with capsys.disabled(): notebook, _, _, result = buildNotebook(DEMO_BINARY, remote) assert len(result.reportCells) > 0 assert notebook
def test_notebook_build(capsys): """ Test to confirm a Jupyter notebook can be creating from profile information and results generated by xpedite record """ with capsys.disabled(): notebook, _, _, result = buildNotebook(DATA_DIR, FIX_DECODER_BINARY, TXN_COUNT, THREAD_COUNT, REMOTE) assert len(result.reportCells) > 0 assert notebook
def test_notebook_build(capsys, scenarioName): """ Test to confirm a Jupyter notebook can be creating from profile information and results generated by xpedite record """ checkPmcSupport(scenarioName) with SCENARIO_LOADER[scenarioName] as scenarios: with capsys.disabled(): notebook, _, report, _, _ = buildNotebook(CONTEXT, scenarios) assert report.categories assert notebook
def generateBaseline(context, scenario): """ Generate the following files for an application scenario: Parameters: - Xpedite application information file - (xpedite-appinfo.txt) Used to test building of notebooks Expected Results: - Profile data file generated from building a Jupyter notebook - (reportCmdBaseline.xpd) Used to compare results from profiling against previous results - Xpedite .data files - (xpedite-<app_name>-<run_id>.data) Used to recreate profiles from the same sample files to test profiling - An automatically generated profile information file (generateCmdBaseline.py) Used to test Xpedite's profile info generate functionality - Serialized probe baseline map - (probeCmdBaseline.pkl) Used to compare probe states generated by an xpedite app to baseline probes These files are stored in tar files separated by application and scenario """ os.mkdir(os.path.join(scenario.dataDir, PARAMETERS_DATA_DIR)) os.mkdir(os.path.join(scenario.dataDir, EXPECTED_RESULTS)) with scenario as _: if scenario.scenarioType == ScenarioType.Benchmark: benchmarkProfile(context, scenario) _, dataFilePath, report, fullCpuInfo, dataFiles = buildNotebook( context, scenario) copy(dataFilePath, os.path.join(scenario.dataDir, REPORT_CMD_BASELINE_PATH)) for dataFile in dataFiles: copy( dataFile, os.path.join(scenario.dataDir, PARAMETERS_DATA_DIR, os.path.basename(dataFile))) replaceWorkspace( report.app.appInfoPath, context.workspace, os.path.join(scenario.dataDir, XPEDITE_APP_INFO_PARAMETER_PATH)) from xpedite.util.cpuInfo import CpuInfoJSONEncoder with open(os.path.join(scenario.dataDir, BASELINE_CPU_INFO_PATH), 'w') as fileHandle: json.dump(fullCpuInfo, fileHandle, cls=CpuInfoJSONEncoder) probes = loadProbes(context, scenario) copy(os.path.abspath(generateProfileInfoFile(report.app, probes)), os.path.join(scenario.dataDir, GENERATE_CMD_BASELINE_PATH)) baselineProbeMap = {} for probe in probes: baselineProbeMap[probe.sysName] = probe with open(os.path.join(scenario.dataDir, PROBE_CMD_BASELINE_PATH), 'wb') as probeFileHandle: probeFileHandle.write(pickle.dumps(baselineProbeMap)) # pylint: disable=c-extension-no-member
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))