def generateProfiles(self, name, txnRepo, classifier): """ Generates profiles for the current profile session :param txnRepo: Repository of loaded transactions :param classifier: Predicate to classify transactions into different categories """ from xpedite.profiler.profile import Profiles, Profile txnTree, benchmarkCompositeTree = self.buildTxnTree(txnRepo, classifier) profiles = Profiles(name, txnRepo) for category, categoryNode in txnTree.getChildren().items(): i = 1 for route, txnNode in categoryNode.children.items(): routeName = ' [route - {}]'.format(i) if len(categoryNode.children) > 1 else '' profileName = '{} - {}{}'.format(name, category, routeName) begin = time.time() LOGGER.info('generating profile %s (txns - %d) -> ', profileName, len(txnNode.collection)) benchmarkTxnsMap = benchmarkCompositeTree.getCollectionMap([category, route]) reportProbes = self.mapReportProbes(route, txnRepo.getCurrent().probes) timelineStats, benchmarkTimelineStats = self.computeStats( txnRepo, category, route, reportProbes, txnNode.collection, benchmarkTxnsMap ) profiles.addProfile(Profile(profileName, timelineStats, benchmarkTimelineStats)) elapsed = time.time() - begin LOGGER.completed('completed in %0.2f sec.', elapsed) i += 1 return profiles
def copyProfileLayout(srcProfile, category, route): """ Creates a new Profile, cloning layout from a source profile :param srcProfile: Source profile to clone :param route: Route of transactions in the new profile :param category: Category of transactions in the new profile """ profile = Profile( srcProfile.name, current=Conflator.createTimelineStats(srcProfile.current, category, route), benchmarks={} ) return profile
def filterProfile(self, srcProfile): """ Filters timelines from a source profile :param srcProfile: source profile to be filtered """ current = self.filterTimelineStats(srcProfile.current) if not current: return None dstProfile = Profile(srcProfile.name, current, {}) for name, tls in srcProfile.benchmarks.iteritems(): filteredtls = self.filterTimelineStats(tls) if filteredtls: dstProfile.benchmarks.update({name: filteredtls}) return dstProfile