Beispiel #1
0
def plot(routePoints=None, profiles=None):
  """
  Creates visualization for a one or more conflated timeline(s)

  :param routePoints: Indices of the conflated route (Default value = None)
  :param profiles: Profiles with timelines to plot (Default value = None)

  """
  if isinstance(routePoints, int):
    from xpedite.jupyter.plot               import buildTxnPlot, buildPmcPlot
    from xpedite.analytics.timelineFilter   import locateTimeline
    profiles = profiles if profiles else globalProfile()
    txnId = routePoints
    timeline = locateTimeline(profiles, txnId)
    if timeline:
      display(HTML(buildTxnPlot(timeline)))
      if profiles.pmcNames:
        display(HTML(buildPmcPlot(timeline)))
      return
    display(HTML(ERROR_TEXT.format('cannot find transaction for id {}'.format(txnId))))
    return
  from xpedite.report.flot import FlotBuilder
  profile = conflate(profiles, routePoints)
  if profile:
    flot = FlotBuilder().buildBenchmarkFlot(profile.category, profile.current, profile.benchmarks)
    display(HTML(str(flot)))
Beispiel #2
0
def diffTxns(lhs, rhs, profiles):
  """
  Compares statistics for a group of transactions

  :param lhs: A list of transaction ids (lhs value of comparison)
  :param rhs: A list of transaction ids (rhs value of comparison)
  :param profiles: Transactions from the current profile session
  :type profiles: xpedite.report.profile.Profiles

  """
  from xpedite.analytics.timelineFilter   import locateTimeline
  from xpedite.analytics.conflator        import Conflator
  from xpedite.report.stats               import StatsBuilder

  lhs = [lhs] if not isinstance(lhs, list) else lhs
  rhs = [rhs] if not isinstance(rhs, list) else rhs
  if not all(isinstance(txn, int) for txn in lhs) or not all(isinstance(txn, int) for txn in rhs):
    display(HTML(ERROR_TEXT.format(
      'Arguments must contain only valid txn ids (integers), example - diff([1, 2, 3, ... ], 1000)'
    )))
    return
  try:
    _ = [locateTimeline(profiles, timeline).txn for timeline in lhs]
    _ = [locateTimeline(profiles, timeline).txn for timeline in rhs]
  except Exception:
    display(HTML(ERROR_TEXT.format(
      'Can\'t locate one or more transactions, Are these valid txn id\'s?'
    )))
    return

  lhsProfiles = filter(lambda txn: txn.txnId in lhs)
  rhsProfiles = filter(lambda txn: txn.txnId in rhs)

  for i, profile in enumerate(lhsProfiles.profiles):
    category = 'Route #{}'.format(i)
    rhsProfile = Conflator().conflateProfiles(rhsProfiles.profiles, profile.route, category)
    if rhsProfile and len(rhsProfile.current) == 1 and len(profile.current) == 1:
      diffTxn(profile.current[0].txnId, rhsProfile.current[0].txnId, profiles)
    elif rhsProfile and rhsProfile.current:
      display(HTML(str(StatsBuilder().buildStatsTable(category, profile.current, {category : rhsProfile.current}))))
    else:
      display(HTML(ERROR_TEXT.format(
        'route {} with {} txns occurs only in one side of equality'.format(profile.route, rhs.current)
      )))
Beispiel #3
0
  def txns(self, routePoints=None):
    """
    Conflates timelines across profiles with the given route points

    :param routePoints: Indices of the conflated route (Default value = None)

    """
    if self.profiles:
      return txns(routePoints, self.profiles)
    display(HTML(ERROR_TEXT.format('No matching transactions found')))
    return None
Beispiel #4
0
def diffTxn(lhs, rhs, profiles):
  """
  Compares duration/pmc values for a pair of transactions

  :param lhs: Transaction id (lhs value of comparison)
  :type lhs: int
  :param rhs: Transaction id (rhs value of comparison)
  :type rhs: int
  :param profiles: Transactions from the current profile session
  :type profiles: xpedite.report.profile.Profiles

  """
  from xpedite.analytics.timelineFilter   import locateTimeline
  from xpedite.report.diff                import DiffBuilder
  from xpedite.types.route                import conflateRoutes
  from xpedite.analytics.conflator        import Conflator

  timeline1 = locateTimeline(profiles, lhs)
  timeline2 = locateTimeline(profiles, rhs)
  if timeline1 and timeline2:
    lhs, rhs = (timeline1, timeline2) if len(timeline1) > len(timeline2) else (timeline2, timeline1)
    routeIndices = conflateRoutes(lhs.txn.route, rhs.txn.route)
    if not routeIndices:
      display(HTML(ERROR_TEXT.format('Transactions {} and {} are not comparable'.format(lhs.txnId, rhs.txnId))))
      return
    topdownMetrics = Conflator().getTopdownMetrics(profiles.cpuInfo.cpuId, profiles.topdownKeys)
    conflatedTimeline = Conflator().conflateTimeline(lhs, routeIndices, profiles.eventsMap, topdownMetrics)
    display(HTML(str(DiffBuilder().buildDiffTable(conflatedTimeline, rhs))))
  else:
    if not (timeline1 or timeline2):
      display(HTML(ERROR_TEXT.format(
        'Can\'t find transactions. Are these ({} and {}) valid txn id\'s?'.format(lhs, rhs)
      )))
    else:
      txnId = rhs if timeline1 else lhs
      display(HTML(ERROR_TEXT.format('Can\'t find transaction {}, is the txn id valid?'.format(txnId))))
Beispiel #5
0
def diff(lhs, rhs, profiles=None):
  """
  Compares statistics for a pair or a group of transactions

  :param lhs: Transaction ID or A list of transaction ids (lhs value of comparison)
  :param rhs: Transaction ID or A list of transaction ids (rhs value of comparison)
  :param profiles: Transactions from the current profile session
  :type profiles: xpedite.report.profile.Profiles

  """
  profiles = profiles if profiles else globalProfile()
  if isinstance(lhs, int) and isinstance(rhs, int):
    diffTxn(lhs, rhs, profiles)
  elif isinstance(lhs, list) or isinstance(rhs, list):
    diffTxns(lhs, rhs, profiles)
  else:
    display(HTML(ERROR_TEXT.format(
"""
Invalid arguments:<br>
diff expects either a pair of txns or a pair of list of txns<br>
usage 1: diff(&lt;txnId1&gt;, &lt;txnId2&gt;) - compares two transactions with id txnId1 vs txnId2<br>
usage 2: diff(&lt;List of txns&gt;, &lt;List of txns&gt;) - compares stats for the first list of txns vs the second.<br>
"""
    )))