示例#1
0
  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
示例#2
0
    def apply(self, profiles):
        """
    Filters timelines from a collection of profiles

    :param profiles: collection of profiles to be filtered

    """
        filtredProfiles = Profiles(profiles.transactionRepo)
        for profile in profiles:
            filteredProfile = self.filterProfile(profile)
            if filteredProfile:
                filtredProfiles.addProfile(filteredProfile)
        return filtredProfiles