def test_topdown_command(cpuId): """ Test display of topdown hierarchy """ pmuResults = PMU_RESULTS_LOADER[cpuId] topdown = Topdown(loadEventsDb(cpuId)) assert str(topdown.hierarchy).split('\n') == pmuResults.topdownBaseline
def test_metrics_command(cpuId): """ Test generating topdown metrics display """ pmuResults = PMU_RESULTS_LOADER[cpuId] topdown = Topdown(loadEventsDb(cpuId)) metrics = '\n'.join([topdown.metricsToString(name) for name in topdown.metrics()]) assert metrics.split('\n') == pmuResults.metricsBaseline[:-1]
def test_list_command(cpuId): """ Test listing contents of eventsDb """ pmuResults = PMU_RESULTS_LOADER[cpuId] eventsDb = loadEventsDb(cpuId) events = '\n'.join([str(event) for event in eventsDb.eventsMap.values()]) assert events.split('\n') == pmuResults.eventsDbBaseline[:-1]
def getEventsDb(self, cpuId): """ Loads and caches PMU events database for the given cpu id :param cpuId: target cpu id for eventsDb """ from xpedite.pmu.eventsDb import loadEventsDb if cpuId not in self.eventsDbRepo: self.eventsDbRepo.update({cpuId: loadEventsDb(cpuId)}) return self.eventsDbRepo[cpuId]
def main(): """ Generate baseline files for each CPU supported """ parser = argparse.ArgumentParser() parser.add_argument( '--rundir', help='temporary directory where files have been unzipped') args = parser.parse_args() if not os.path.exists(os.path.join(args.rundir, PMU_DATA)): os.mkdir(os.path.join(args.rundir, PMU_DATA)) for cpuId in CPU_IDS: eventsDb = loadEventsDb(cpuId) if not os.path.exists(os.path.join(args.rundir, PMU_DATA, cpuId)): os.mkdir(os.path.join(args.rundir, PMU_DATA, cpuId)) topdown = Topdown(eventsDb) with open( os.path.join(args.rundir, PMU_DATA, cpuId, METRICS_FILE_NAME), 'w') as fileHandle: metrics = [ '{}\n'.format(topdown.metricsToString(name)) for name in topdown.metrics() ] fileHandle.writelines(metrics) with open( os.path.join(args.rundir, PMU_DATA, cpuId, TOPDOWN_FILE_NAME), 'w') as fileHandle: fileHandle.write(str(topdown.hierarchy)) with open( os.path.join(args.rundir, PMU_DATA, cpuId, EVENTS_DB_FILE_NAME), 'w') as fileHandle: events = [ '{}\n'.format(str(event)) for event in eventsDb.eventsMap.values() ] fileHandle.writelines(events)