tools/perf/cli_tools/pinboard/pinboard.py
def GetRevisionResults(item):
  """Aggregate the results from jobs that ran on a particular revision."""
  # First load pinpoint csv results into a DataFrame. The dtype arg is needed
  # to ensure that job_id's are always read a strings (even if some of them
  # look like large numbers).
  df = pd.read_csv(RevisionResultsFile(item), dtype={'job_id': str})
  assert df['change'].str.contains(item['revision']).all(), (
      'Not all results match the expected git revision')

  # Filter out and keep only the measurements and stories that we want.
  df = df[df['name'].isin(MEASUREMENTS)]
  df = df[df['story'].isin(ACTIVE_STORIES)]

  if not df.empty:
    # Aggregate over the results of individual stories.
    df = df.groupby(['change', 'job_id', 'name', 'benchmark',
                     'unit'])['mean'].agg(['mean', 'count']).reset_index()
  else:
    # Otherwise build a single row with an "empty" aggregate for this revision.
    # This is needed so we can remember in the cache that this revision has
    # been processed.
    df = pd.DataFrame(index=[0])
    df['change'] = item['revision']
    df['job_id'] = '(missing)'
    df['name'] = '(missing)'
    df['benchmark'] = '(missing)'
    df['unit'] = ''
    df['mean'] = np.nan
    df['count'] = 0

  # Convert time units from milliseconds to seconds. This is what Data Studio
  # dashboards expect.
  is_ms_unit = df['unit'].str.startswith('ms_')
  df.loc[is_ms_unit, 'mean'] = df['mean'] / 1000

  # Distinguish jobs that ran with/without the tested patch.
  df['label'] = df['change'].str.contains(r'\+').map(
      {False: 'without_patch', True: 'with_patch'})

  # Add timestamp and revision information. We snap the date to noon and make
  # it naive (i.e. no timezone), so the dashboard doesn't get confused with
  # dates close to the end of day.
  date = item['timestamp'].split('T')[0] + 'T12:00:00'
  df['timestamp'] = pd.Timestamp(date)
  df['revision'] = item['revision']

  # Fake the timestamp of jobs without the patch to appear as if they ran a
  # year ago; this makes it easier to visualize and compare timeseries from
  # runs with/without the patch in Data Studio dashboards.
  df.loc[df['label'] == 'without_patch', 'timestamp'] = (
      df['timestamp'] - pd.DateOffset(years=1))

  df['bot'] = 'unknown'
  df['patch'] = 'unknown'
  for j in item['jobs']:
    bot = j.get('bot', 'unknown')
    patch = j.get('patch', 'unknown')
    df.loc[df['job_id'].str.contains(str(j['id'])), 'bot'] = bot
    df.loc[df['job_id'].str.contains(str(j['id'])), 'patch'] = patch

  return df[[
      'revision', 'timestamp', 'bot', 'patch', 'label', 'benchmark', 'name',
      'mean', 'count'
  ]]
Aggregate the results from jobs that ran on a particular revision.
Aggregate the results from jobs that ran on a particular revision.
Aggregate the results from jobs that ran on a particular revision .
def GetRevisionResults(item):
  df = pd.read_csv(RevisionResultsFile(item), dtype={'job_id': str})
  assert df['change'].str.contains(item['revision']).all(), (
      'Not all results match the expected git revision')
  df = df[df['name'].isin(MEASUREMENTS)]
  df = df[df['story'].isin(ACTIVE_STORIES)]
  if not df.empty:
    df = df.groupby(['change', 'job_id', 'name', 'benchmark',
                     'unit'])['mean'].agg(['mean', 'count']).reset_index()
  else:
    df = pd.DataFrame(index=[0])
    df['change'] = item['revision']
    df['job_id'] = '(missing)'
    df['name'] = '(missing)'
    df['benchmark'] = '(missing)'
    df['unit'] = ''
    df['mean'] = np.nan
    df['count'] = 0
  is_ms_unit = df['unit'].str.startswith('ms_')
  df.loc[is_ms_unit, 'mean'] = df['mean'] / 1000
  df['label'] = df['change'].str.contains(r'\+').map(
      {False: 'without_patch', True: 'with_patch'})
  date = item['timestamp'].split('T')[0] + 'T12:00:00'
  df['timestamp'] = pd.Timestamp(date)
  df['revision'] = item['revision']
  df.loc[df['label'] == 'without_patch', 'timestamp'] = (
      df['timestamp'] - pd.DateOffset(years=1))
  df['bot'] = 'unknown'
  df['patch'] = 'unknown'
  for j in item['jobs']:
    bot = j.get('bot', 'unknown')
    patch = j.get('patch', 'unknown')
    df.loc[df['job_id'].str.contains(str(j['id'])), 'bot'] = bot
    df.loc[df['job_id'].str.contains(str(j['id'])), 'patch'] = patch
  return df[[
      'revision', 'timestamp', 'bot', 'patch', 'label', 'benchmark', 'name',
      'mean', 'count'
  ]]
def GetRevisionResults ( item ) : df = pd . read_csv ( RevisionResultsFile ( item ) , dtype = { 'job_id' : str } ) assert df [ 'change' ] . str . contains ( item [ 'revision' ] ) . all ( ) , ( 'Not all results match the expected git revision' ) df = df [ df [ 'name' ] . isin ( MEASUREMENTS ) ] df = df [ df [ 'story' ] . isin ( ACTIVE_STORIES ) ] if not df . empty : df = df . groupby ( [ 'change' , 'job_id' , 'name' , 'benchmark' , 'unit' ] ) [ 'mean' ] . agg ( [ 'mean' , 'count' ] ) . reset_index ( ) else : df = pd . DataFrame ( index = [ 0 ] ) df [ 'change' ] = item [ 'revision' ] df [ 'job_id' ] = '(missing)' df [ 'name' ] = '(missing)' df [ 'benchmark' ] = '(missing)' df [ 'unit' ] = '' df [ 'mean' ] = np . nan df [ 'count' ] = 0 is_ms_unit = df [ 'unit' ] . str . startswith ( 'ms_' ) df . loc [ is_ms_unit , 'mean' ] = df [ 'mean' ] / 1000 df [ 'label' ] = df [ 'change' ] . str . contains ( r'\+' ) . map ( { False : 'without_patch' , True : 'with_patch' } ) date = item [ 'timestamp' ] . split ( 'T' ) [ 0 ] + 'T12:00:00' df [ 'timestamp' ] = pd . Timestamp ( date ) df [ 'revision' ] = item [ 'revision' ] df . loc [ df [ 'label' ] == 'without_patch' , 'timestamp' ] = ( df [ 'timestamp' ] - pd . DateOffset ( years = 1 ) ) df [ 'bot' ] = 'unknown' df [ 'patch' ] = 'unknown' for j in item [ 'jobs' ] : bot = j . get ( 'bot' , 'unknown' ) patch = j . get ( 'patch' , 'unknown' ) df . loc [ df [ 'job_id' ] . str . contains ( str ( j [ 'id' ] ) ) , 'bot' ] = bot df . loc [ df [ 'job_id' ] . str . contains ( str ( j [ 'id' ] ) ) , 'patch' ] = patch return df [ [ 'revision' , 'timestamp' , 'bot' , 'patch' , 'label' , 'benchmark' , 'name' , 'mean' , 'count' ] ]
Aggregate the results from jobs that ran on a particular revision.
Aggregate the results from jobs that ran on a particular revision .
"""Aggregate the results from jobs that ran on a particular revision.""" # First load pinpoint csv results into a DataFrame. The dtype arg is needed # to ensure that job_id's are always read a strings (even if some of them # look like large numbers). # Filter out and keep only the measurements and stories that we want. # Aggregate over the results of individual stories. # Otherwise build a single row with an "empty" aggregate for this revision. # This is needed so we can remember in the cache that this revision has # been processed. # Convert time units from milliseconds to seconds. This is what Data Studio # dashboards expect. # Distinguish jobs that ran with/without the tested patch. # Add timestamp and revision information. We snap the date to noon and make # it naive (i.e. no timezone), so the dashboard doesn't get confused with # dates close to the end of day. # Fake the timestamp of jobs without the patch to appear as if they ran a # year ago; this makes it easier to visualize and compare timeseries from # runs with/without the patch in Data Studio dashboards.
item