def loadCounter(self, threadId, loader, probes, record): """ Loads time and pmu counters from the given record :param threadId: Id of thread collecting the samples :param loader: loader to build transactions out of the counters :param probes: Map of probes instrumented in target application :param record: A sample record in csv format """ fields = record.split(',') if len(fields) < self.MIN_FIELD_COUNT: raise Exception( 'detected record with < {} fields - \nrecord: "{}"\n'.format( self.MIN_FIELD_COUNT, record)) addr = fields[self.INDEX_ADDR] if addr not in probes: self.orphanedSamplesCount += 1 return None data = fields[self.INDEX_DATA] tsc = int(fields[self.INDEX_TSC], 16) counter = Counter(threadId, probes[addr], data, tsc) if len(fields) > self.MIN_FIELD_COUNT: for pmc in fields[self.MIN_FIELD_COUNT + 1:]: counter.addPmc(int(pmc)) if self.counterFilter.canLoad(counter): loader.loadCounter(counter) return counter
def loadSample(self, threadId, loader, probes, sample): """ Loads time and pmu counters from xpedite sample objects :param threadId: Id of thread collecting the samples :param loader: loader to build transactions out of the counters :param probes: Map of probes instrumented in target application :param sample: An object with binding to underlying C++ Sample object """ addr = hex(sample.returnSite()) if addr not in probes: self.orphanedSamplesCount += 1 return None data = sample.dataStr() if sample.hasData() else '' counter = Counter(threadId, probes[addr], data, sample.tsc()) if sample.hasPmc(): for i in range(sample.pmcCount()): counter.addPmc(sample.pmc(i)) if self.counterFilter.canLoad(counter): loader.loadCounter(counter) return counter