コード例 #1
0
ファイル: test_profiler.py プロジェクト: xwlan/Xpedite
def test_probe_states(capsys):
    """
  Test xpedite probes and probes state for an application's against baseline probe states
  for the application
  """
    import cPickle as pickle
    from xpedite.types.probe import compareProbes
    profileInfo = loadProfileInfo(DATA_DIR,
                                  os.path.join(DATA_DIR, 'profileInfo.py'),
                                  REMOTE)
    probes = []
    probeMap = {}
    baselineProbeMap = {}
    with capsys.disabled():
        probes = loadProbes(FIX_DECODER_BINARY, profileInfo, TXN_COUNT,
                            THREAD_COUNT, REMOTE, WORKSPACE)
        for probe in probes:
            probeMap[probe.sysName] = probe

    with open(os.path.join(DATA_DIR, 'probeCmdBaseline.pkl'),
              'r') as probeFileHandle:
        baselineProbes = pickle.load(probeFileHandle)
        for probe in baselineProbes:
            baselineProbeMap[probe.sysName] = probe

    assert len(probes) == len(baselineProbes)
    findDiff(probeMap, baselineProbeMap)
    for probe in probeMap.keys():
        assert compareProbes(probeMap[probe], baselineProbeMap[probe])
コード例 #2
0
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
コード例 #3
0
ファイル: test_profiler.py プロジェクト: ywong587/Xpedite
def test_probe_states(capsys, scenarioName):
  """
  Test xpedite probes and probes state for an application's against baseline probe states
  for the application
  """
  from xpedite.types.probe import compareProbes
  with SCENARIO_LOADER[scenarioName] as scenarios:
    probeMap = {}
    with capsys.disabled():
      probes = loadProbes(CONTEXT, scenarios)
      for probe in probes:
        probeMap[probe.sysName] = probe
    assert len(probes) == len(scenarios.baselineProbeMap)
    findDiff(probeMap, scenarios.baselineProbeMap)
    for probe in probeMap:
      assert compareProbes(probeMap[probe], scenarios.baselineProbeMap[probe])
コード例 #4
0
ファイル: test_profiler.py プロジェクト: kelliott55/Xpedite
def test_probe_states(capsys):
    """
  Test xpedite probes and probes state for an application's against baseline probe states
  for the application
  """
    import cPickle as pickle
    from xpedite.probe import compareProbes
    profileInfo = loadProfileInfo(os.path.join(dataDir, 'profileInfo.py'),
                                  remote)
    probes = []
    with capsys.disabled():
        probes = loadProbes(DEMO_BINARY, profileInfo, remote)

    with open(os.path.join(dataDir, 'probeBaseline.pkl'),
              'r') as probeFileHandle:
        baselineProbes = pickle.load(probeFileHandle)

    assert len(probes) == len(baselineProbes)
    for i in range(len(probes)):
        assert compareProbes(probes[i], baselineProbes[i])
コード例 #5
0
ファイル: generateBaseline.py プロジェクト: xwlan/Xpedite
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))