experimental/v8_tools/filter.js
function readSingleFile(e) {
  const file = e.target.files[0];
  if (!file) {
    return;
  }
  //  Extract data from file and distribute it in some relevant structures:
  //  results for all guid-related( for now they are not
  //  divided in 3 parts depending on the type ) and
  //  all results with sample-value-related and
  //  map guid to value within the same structure
  const reader = new FileReader();
  reader.onload = function(e) {
    const contents = extractData(e.target.result);
    const sampleArr = contents.sampleValueArray;
    const guidValueInfo = contents.guidValueInfo;
    const metricAverage = new Map();
    const allLabels = new Set();
    for (const e of sampleArr) {
      // This version of the tool focuses on analysing memory
      // metrics, which contain a slightly different structure
      // to the non-memory metrics.
      if (e.name.startsWith('memory')) {
        const { name, sampleValues, diagnostics } = e;
        const { labels, stories } = diagnostics;
        const label = guidValueInfo.get(labels)[0];
        allLabels.add(label);
        const story = guidValueInfo.get(stories)[0];
        menu.significanceTester.add(name, label, story, sampleValues);
      }
    }
    menu.allLabels = Array.from(allLabels);
    let metricNames = [];
    sampleArr.map(e => metricNames.push(e.name));
    metricNames = _.uniq(metricNames);


    //  The content for the default table: with name
    //  of the metric, the average value of the sample values
    //  plus an id. The latest is used to expand the row.
    //  It may disappear later.
    const tableElems = [];
    let id = 1;
    for (const name of metricNames) {
      tableElems.push({
        id: id++,
        metric: name
      });
    }

    const labelsResult = getMetricStoriesLabelsToValuesMap(
        sampleArr, guidValueInfo);
    const columnsForChosenDiagnostic = labelsResult.labelNames;
    const metricToDiagnosticValuesMap = labelsResult.mapLabelToValues;
    for (const elem of tableElems) {
      if (metricToDiagnosticValuesMap.get(elem.metric) === undefined) {
        continue;
      }
      for (const diagnostic of columnsForChosenDiagnostic) {
        if (!metricToDiagnosticValuesMap.get(elem.metric).has(diagnostic)) {
          continue;
        }
        elem[diagnostic] = fromBytesToMiB(average(metricToDiagnosticValuesMap
            .get(elem.metric).get(diagnostic)));
      }
    }


    app.state.gridData = tableElems;
    app.defaultGridData = tableElems;
    app.sampleArr = sampleArr;
    app.guidValue = guidValueInfo;
    app.columnsForChosenDiagnostic = columnsForChosenDiagnostic;

    const result = parseAllMetrics(metricNames);
    menu.sampelArr = sampleArr;
    menu.guidValueInfo = guidValueInfo;

    menu.browserOptions = result.browsers;
    menu.subprocessOptions = result.subprocesses;
    menu.componentMap = result.components;
    menu.sizeMap = result.sizes;
    menu.metricNames = result.names;
  };
  reader.readAsText(file);
}
function readSingleFile(e) {
  const file = e.target.files[0];
  if (!file) {
    return;
  }
  //  Extract data from file and distribute it in some relevant structures:
  //  results for all guid-related( for now they are not
  //  divided in 3 parts depending on the type ) and
  //  all results with sample-value-related and
  //  map guid to value within the same structure
  const reader = new FileReader();
  reader.onload = function(e) {
    const contents = extractData(e.target.result);
    const sampleArr = contents.sampleValueArray;
    const guidValueInfo = contents.guidValueInfo;
    const metricAverage = new Map();
    const allLabels = new Set();
    for (const e of sampleArr) {
      // This version of the tool focuses on analysing memory
      // metrics, which contain a slightly different structure
      // to the non-memory metrics.
      if (e.name.startsWith('memory')) {
        const { name, sampleValues, diagnostics } = e;
        const { labels, stories } = diagnostics;
        const label = guidValueInfo.get(labels)[0];
        allLabels.add(label);
        const story = guidValueInfo.get(stories)[0];
        menu.significanceTester.add(name, label, story, sampleValues);
      }
    }
    menu.allLabels = Array.from(allLabels);
    let metricNames = [];
    sampleArr.map(e => metricNames.push(e.name));
    metricNames = _.uniq(metricNames);


    //  The content for the default table: with name
    //  of the metric, the average value of the sample values
    //  plus an id. The latest is used to expand the row.
    //  It may disappear later.
    const tableElems = [];
    let id = 1;
    for (const name of metricNames) {
      tableElems.push({
        id: id++,
        metric: name
      });
    }

    const labelsResult = getMetricStoriesLabelsToValuesMap(
        sampleArr, guidValueInfo);
    const columnsForChosenDiagnostic = labelsResult.labelNames;
    const metricToDiagnosticValuesMap = labelsResult.mapLabelToValues;
    for (const elem of tableElems) {
      if (metricToDiagnosticValuesMap.get(elem.metric) === undefined) {
        continue;
      }
      for (const diagnostic of columnsForChosenDiagnostic) {
        if (!metricToDiagnosticValuesMap.get(elem.metric).has(diagnostic)) {
          continue;
        }
        elem[diagnostic] = fromBytesToMiB(average(metricToDiagnosticValuesMap
            .get(elem.metric).get(diagnostic)));
      }
    }


    app.state.gridData = tableElems;
    app.defaultGridData = tableElems;
    app.sampleArr = sampleArr;
    app.guidValue = guidValueInfo;
    app.columnsForChosenDiagnostic = columnsForChosenDiagnostic;

    const result = parseAllMetrics(metricNames);
    menu.sampelArr = sampleArr;
    menu.guidValueInfo = guidValueInfo;

    menu.browserOptions = result.browsers;
    menu.subprocessOptions = result.subprocesses;
    menu.componentMap = result.components;
    menu.sizeMap = result.sizes;
    menu.metricNames = result.names;
  };
  reader.readAsText(file);
}
function readSingleFile ( e ) { const file = e . target . files [ 0 ] ; if ( ! file ) { return ; } //  Extract data from file and distribute it in some relevant structures: //  results for all guid-related( for now they are not //  divided in 3 parts depending on the type ) and //  all results with sample-value-related and //  map guid to value within the same structure const reader = new FileReader ( ) ; reader . onload = function ( e ) { const contents = extractData ( e . target . result ) ; const sampleArr = contents . sampleValueArray ; const guidValueInfo = contents . guidValueInfo ; const metricAverage = new Map ( ) ; const allLabels = new Set ( ) ; for ( const e of sampleArr ) { // This version of the tool focuses on analysing memory // metrics, which contain a slightly different structure // to the non-memory metrics. if ( e . name . startsWith ( 'memory' ) ) { const { name , sampleValues , diagnostics } = e ; const { labels , stories } = diagnostics ; const label = guidValueInfo . get ( labels ) [ 0 ] ; allLabels . add ( label ) ; const story = guidValueInfo . get ( stories ) [ 0 ] ; menu . significanceTester . add ( name , label , story , sampleValues ) ; } } menu . allLabels = Array . from ( allLabels ) ; let metricNames = [ ] ; sampleArr . map ( e => metricNames . push ( e . name ) ) ; metricNames = _ . uniq ( metricNames ) ; //  The content for the default table: with name //  of the metric, the average value of the sample values //  plus an id. The latest is used to expand the row. //  It may disappear later. const tableElems = [ ] ; let id = 1 ; for ( const name of metricNames ) { tableElems . push ( { id : id ++ , metric : name } ) ; } const labelsResult = getMetricStoriesLabelsToValuesMap ( sampleArr , guidValueInfo ) ; const columnsForChosenDiagnostic = labelsResult . labelNames ; const metricToDiagnosticValuesMap = labelsResult . mapLabelToValues ; for ( const elem of tableElems ) { if ( metricToDiagnosticValuesMap . get ( elem . metric ) === undefined ) { continue ; } for ( const diagnostic of columnsForChosenDiagnostic ) { if ( ! metricToDiagnosticValuesMap . get ( elem . metric ) . has ( diagnostic ) ) { continue ; } elem [ diagnostic ] = fromBytesToMiB ( average ( metricToDiagnosticValuesMap . get ( elem . metric ) . get ( diagnostic ) ) ) ; } } app . state . gridData = tableElems ; app . defaultGridData = tableElems ; app . sampleArr = sampleArr ; app . guidValue = guidValueInfo ; app . columnsForChosenDiagnostic = columnsForChosenDiagnostic ; const result = parseAllMetrics ( metricNames ) ; menu . sampelArr = sampleArr ; menu . guidValueInfo = guidValueInfo ; menu . browserOptions = result . browsers ; menu . subprocessOptions = result . subprocesses ; menu . componentMap = result . components ; menu . sizeMap = result . sizes ; menu . metricNames = result . names ; } ; reader . readAsText ( file ) ; }
Load the content of the file and further display the data.
Load the content of the file and further display the data .