def buildTxnTree(txnRepo, txnClassifier): """ Builds Transaction tree collections for current profile sesssion and benchmarks :param repo: Repository of transaction collections from current profile session and benchmarks :param txnClassifier: Predicate to classify transactions into different categories """ mustHaveProbes = None treeClassifiers = [ lambda txnSubCollection, ancestry: TxnAggregator.groupTxns( txnSubCollection, classifier=txnClassifier, mustHaveProbes=mustHaveProbes), lambda txnSubCollection, ancestry: RouteAggregator.aggregateTxnsByRoutes(txnSubCollection) ] txnTree = TreeCollectionFactory.buildTreeCollection( txnRepo.getCurrent().name, txnRepo.getCurrent().getSubCollection(), treeClassifiers) treeClassifiers[1] = RouteConflatingAggregator( txnTree).aggregateTxnsByRoutes benchmarkCompositeTree = TreeCollectionFactory.buildCompositeTreeCollection( { name: collection.getSubCollection() for name, collection in txnRepo.getBenchmarks().items() }, treeClassifiers) return (txnTree, benchmarkCompositeTree)
def buildElapsedTimeBundles(txnCollections, classifier): """ Builds elapsed timestamp counters for each of the categories in given transaction collections :param repo: List of transaction collections from current profile session and benchmarks :param classifier: Predicate to classify transactions into different categories """ elapsedTscBundles = {} categorySet = set() for i, txnCollection in enumerate(txnCollections): txnSubCollection = txnCollection.getSubCollection() probes = txnCollection.probes elapsedTscMap = timeAction( 'aggregating time stamp counters per transaction', lambda txnsc=txnSubCollection, txnCollection=txnCollection: TxnAggregator.groupElapsedTime( txnsc, txnCollection.cpuInfo, classifier=classifier)) if elapsedTscMap: for category, elapsedTscList in elapsedTscMap.items(): if category in elapsedTscBundles: elapsedTscBundles[category].append(elapsedTscList) else: if i == 0: elapsedTscBundles.update( {category: [elapsedTscList]}) else: if category not in categorySet: categorySet.add(category) LOGGER.warn( 'current run missing trasactions for category "%s"', category) else: scopeList = ', '.join([ probe.getCanonicalName() for probe in probes if not probe.isAnonymous ]) errMsg = ( """{}({}) doesn\'t have any transaction (#{} loaded) with probes\n\t[{}] Did you generate any of these transactions ?""") errMsg = errMsg.format(' benchmark ' if i > 0 else ' ', txnCollection.name, len(txnSubCollection), scopeList) LOGGER.error(errMsg) if i == 0: raise Exception( 'report generation failed for current run. counters not available' ) return elapsedTscBundles