<!DOCTYPE HTML>
<html>
<!--
Copyright (c) 2012 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<head i18n-values="dir:textdirection;">
<title>TimelineAnalysis tests</title>
<script src="base.js"></script>
<style>
  .timeline-view {
    border: 1px solid black;
    margin: 10px;
  }
  .timeline-find-dialog {
    border: 1px solid black;
    margin: 10px;
  }
</style>
</head>
<body>
  <script>
    base.require('unittest');
    base.require('tracing_controller');
    base.require('test_utils');
    base.require('timeline_model');
    base.require('trace_event_importer');
    base.require('timeline_analysis');
    base.require('timeline_filter');
    base.require('tracks.timeline_counter_track');
    base.require('tracks.timeline_slice_track');
    base.require('tracks.timeline_thread_track');
    base.require('timeline'); /* TODO(nduca): reduce dependency */
  </script>
  <script>
    'use strict';

    var TimelineCounter = tracing.TimelineCounter;
    var TimelineThread = tracing.TimelineThread;
    var TimelineAnalysisView = tracing.TimelineAnalysisView;
    var TimelineModel = tracing.TimelineModel;
    var TimelineThreadTrack = tracks.TimelineThreadTrack;
    var TimelineSelection = tracing.TimelineSelection;
    var TimelineTitleFilter = tracing.TimelineTitleFilter;
    var TimelineCounterTrack = tracks.TimelineCounterTrack;
    var TimelineSliceTrack = tracks.TimelineSliceTrack;
    var newSliceNamed = test_utils.newSliceNamed;
    var newSliceCategory = test_utils.newSliceCategory;

    function createSelectionWithSingleSlice(withCategory) {
      var model = new TimelineModel();
      var t53 = model.getOrCreateProcess(52).getOrCreateThread(53);
      if (withCategory)
        t53.pushSlice(newSliceCategory('foo', 'b', 0, 0.002));
      else
        t53.pushSlice(newSliceNamed('b', 0, 0.002));

      var t53track = new TimelineThreadTrack();
      t53track.thread = t53;

      var selection = new TimelineSelection();
      t53track.addAllObjectsMatchingFilterToSelection(
        new TimelineTitleFilter('b'), selection);
      assertEquals(1, selection.length);

      return selection;
    }

    function createSelectionWithTwoSlices() {
      var events = [
        {name: 'a', args: {}, pid: 52, ts: 520, cat: 'foo', tid: 53, ph: 'B'},
        {name: 'a', args: {}, pid: 52, ts: 560, cat: 'foo', tid: 53, ph: 'E'},
        {name: 'aa', args: {}, pid: 52, ts: 640, cat: 'foo', tid: 53, ph: 'B'},
        {name: 'aa', args: {}, pid: 52, ts: 700, cat: 'foo', tid: 53, ph: 'E'}
      ];
      var model = new TimelineModel(events);

      var t53track = new TimelineThreadTrack();
      t53track.thread = model.processes[52].threads[53];

      var selection = new TimelineSelection();
      t53track.addAllObjectsMatchingFilterToSelection(
        new TimelineTitleFilter('a'), selection);
      assertEquals(2, selection.length);

      return selection;
    }

    function createSelectionWithTwoSlicesSameTitle() {
      var events = [
        {name: 'c', args: {}, pid: 52, ts: 620, cat: 'foo', tid: 53, ph: 'B'},
        {name: 'c', args: {}, pid: 52, ts: 660, cat: 'foo', tid: 53, ph: 'E'},
        {name: 'c', args: {}, pid: 52, ts: 740, cat: 'foo', tid: 53, ph: 'B'},
        {name: 'c', args: {}, pid: 52, ts: 800, cat: 'foo', tid: 53, ph: 'E'}
      ];
      var model = new TimelineModel(events);

      var t53track = new TimelineThreadTrack();
      t53track.thread = model.processes[52].threads[53];

      var selection = new TimelineSelection();
      t53track.addAllObjectsMatchingFilterToSelection(
        new TimelineTitleFilter('c'), selection);
      assertEquals(2, selection.length);

      return selection;
    }

    function createSelectionWithCounters(numSamples) {
      if (numSamples > 2 || numSamples < 1)
        throw new Error('This function only supports 1 or 2 samples');
      var events = [
        {name: 'ctr', args: {'value': 0}, pid: 1, ts: 0, cat: 'foo', tid: 1,
         ph: 'C', id: 0},
        {name: 'ctr', args: {'value': 10}, pid: 1, ts: 10, cat: 'foo', tid: 1,
         ph: 'C', id: 0}
      ];
      var model = new TimelineModel(events);
      var p = model.processes[1];
      var ctr = model.processes[1].counters['foo.ctr[0]'];
      assertEquals('ctr[0]', ctr.name);
      assertEquals(2, ctr.numSamples);
      assertEquals(1, ctr.numSeries);
      assertArrayEquals([0, 0.01], ctr.timestamps);
      assertArrayEquals([0, 10], ctr.samples);

      var selection = new TimelineSelection();
      var t1track = new TimelineThreadTrack();
      selection.addCounterSample(t1track, ctr, 1);

      if (numSamples == 1)
        return selection;

      selection.addCounterSample(t1track, ctr, 0);
      return selection;
    }

    function createSelectionWithTwoSeriesSingleCounter() {
      var events = [
        {name: 'ctr', args: {'bytesallocated': 0, 'bytesfree': 25}, pid: 1,
         ts: 0, cat: 'foo', tid: 1, ph: 'C', id: 0},
        {name: 'ctr', args: {'bytesallocated': 10, 'bytesfree': 15}, pid: 1,
         ts: 10, cat: 'foo', tid: 1, ph: 'C', id: 0},
        {name: 'ctr', args: {'bytesallocated': 20, 'bytesfree': 5}, pid: 1,
         ts: 20, cat: 'foo', tid: 1, ph: 'C', id: 0}
      ];
      var model = new TimelineModel(events);
      var p = model.processes[1];
      var ctr = model.processes[1].counters['foo.ctr[0]'];
      assertEquals('ctr[0]', ctr.name);
      assertEquals(3, ctr.numSamples);
      assertEquals(2, ctr.numSeries);

      var selection = new TimelineSelection();
      var t1track = new TimelineThreadTrack();
      selection.addCounterSample(t1track, ctr, 1);

      return selection;
    }

    function createSelectionWithTwoSeriesTwoCounters() {
      var ctr1 = new TimelineCounter(null, 0, '', 'ctr1');
      ctr1.seriesNames.push('bytesallocated', 'bytesfree');
      ctr1.seriesColors.push(0, 1);
      ctr1.timestamps.push(0, 10, 20);
      ctr1.samples.push(0, 25, 10, 15, 20, 5);

      var ctr2 = new TimelineCounter(null, 0, '', 'ctr2');
      ctr2.seriesNames.push('bytesallocated', 'bytesfree');
      ctr2.seriesColors.push(0, 1);
      ctr2.timestamps.push(0, 10, 20);
      ctr2.samples.push(0, 25, 10, 15, 20, 5);

      var selection = new TimelineSelection();
      var t1track = new TimelineThreadTrack();
      selection.addCounterSample(t1track, ctr1, 1);
      selection.addCounterSample(t1track, ctr2, 2);

      return selection;
    }

    function createSelectionWithTwoCountersDiffSeriesDiffHits() {
      var ctr1 = new TimelineCounter(null, 0, '', 'a');
      ctr1.seriesNames.push('bytesallocated');
      ctr1.seriesColors.push(0);
      ctr1.timestamps.push(0, 10, 20);
      ctr1.samples.push(0, 25, 10);
      assertEquals('a', ctr1.name);
      assertEquals(3, ctr1.numSamples);
      assertEquals(1, ctr1.numSeries);

      var ctr2 = new TimelineCounter(null, 0, '', 'b');
      ctr2.seriesNames.push('bytesallocated', 'bytesfree');
      ctr2.seriesColors.push(0, 1);
      ctr2.timestamps.push(0, 10, 20, 30);
      ctr2.samples.push(0, 25, 10, 15, 20, 5, 25, 0);
      assertEquals('b', ctr2.name);
      assertEquals(4, ctr2.numSamples);
      assertEquals(2, ctr2.numSeries);

      var selection = new TimelineSelection();
      var t1track = new TimelineThreadTrack();
      selection.addCounterSample(t1track, ctr1, 1);
      selection.addCounterSample(t1track, ctr2, 2);

      return selection;
    }

    function createSelectionWithSingleSliceSingleCounter() {
      var model = new TimelineModel();
      var thread = model.getOrCreateProcess(1).getOrCreateThread(1);
      thread.pushSlice(newSliceNamed('b', 1, 5));

      var ctr1 = model.getOrCreateProcess(1).getOrCreateCounter('cat', 'ctr1');
      ctr1.seriesNames.push('bytesallocated', 'bytesfree');
      ctr1.seriesColors.push(0, 1);
      ctr1.timestamps.push(0, 10, 20);
      ctr1.samples.push(0, 25, 10, 15, 20, 5);
      assertEquals('ctr1', ctr1.name);
      assertEquals(3, ctr1.numSamples);
      assertEquals(2, ctr1.numSeries);

      var ctr1track = new TimelineCounterTrack();
      ctr1track.counter = ctr1;

      var threadTrack = new TimelineSliceTrack();
      threadTrack.slices = thread.slices;

      var selection = new TimelineSelection();
      selection.addCounterSample(ctr1track, ctr1, 1);
      threadTrack.addAllObjectsMatchingFilterToSelection(
        new TimelineTitleFilter('b'), selection);
      assertEquals(2, selection.length);
      return selection;
    }

    function createSelectionWithNormallyDistributedSamples(numSlices) {
      // Distance between start times is normally distributed, with mu = 16ms
      // and sigma = 3ms.
      var startTimes = [
        0, 18.4362262859, 32.5378088645, 44.8978868054,
        63.4772725504, 77.438888345, 92.0102867913, 99.6208686689,
        119.150576393, 137.54545468, 153.991587743, 175.456095568,
        193.395772651, 205.691644582, 218.740054982, 239.308480724,
        250.880949151, 268.528689601, 281.950478133, 296.791635722,
        315.862427391, 333.954888221, 342.392899581, 362.364373939,
        377.593380892, 392.296896748, 415.779941407, 435.517713864,
        454.581222491, 470.329018858, 488.37029095, 502.283017166,
        521.15141113, 534.36224697, 554.425018316, 574.89913248,
        589.60294439, 604.780562233, 615.481610668, 630.055628965,
        645.908449096, 661.776084055, 673.276049017, 689.776401428,
        704.440135004, 716.33262401, 732.380086528, 743.970715322,
        756.506690025, 772.391485532, 794.636984401, 803.801415494,
        819.006502926, 837.610127549, 854.551103283, 875.170613672,
        891.508235124, 905.263299017, 929.309555683, 943.417968804,
        957.289319239, 972.302910569, 986.669355637, 1002.71558868,
        1013.83359637, 1030.16840733, 1040.39503139, 1057.61583325,
        1075.64709686, 1086.67671319, 1100.4617455, 1118.4871842,
        1129.98143488, 1144.52318588, 1160.36966285, 1179.50049042,
        1195.03088169, 1215.98199401, 1226.66591838, 1245.83650314,
        1268.18058265, 1285.11047342, 1301.71570575, 1316.40723345,
        1329.94342488, 1343.7569577, 1358.28267513, 1371.17560308,
        1386.42247119, 1401.51767749, 1417.52489051, 1440.98712348,
        1457.80113781, 1475.66079406, 1494.64137536, 1509.52941903,
        1524.54762552, 1545.42960714, 1565.19444597, 1580.56308936,
        1596.72211651];

      var events = [];

      var model = new TimelineModel();
      var thread = model.getOrCreateProcess(52).getOrCreateThread(53);
      var duration = 1; // 1ms

      for (var i = 0; i < startTimes.length; ++i) {
        for (var j = 0; j < numSlices; ++j) {
          var name = 'slice' + String(numSlices - 1 - j);
          thread.slices.push(newSliceNamed(name, startTimes[i], duration));
        }
      }

      var t53track = new TimelineThreadTrack();
      t53track.thread = model.processes[52].threads[53];

      var selection = new TimelineSelection();
      t53track.addAllObjectsMatchingFilterToSelection(
        new TimelineTitleFilter('slice'), selection);
      assertEquals(101 * numSlices, selection.length);

      return selection;
    }

    function testAnalysisViewWithSingleSlice() {
      var selection = createSelectionWithSingleSlice();

      var analysisEl = new TimelineAnalysisView();
      analysisEl.selection = selection;
      this.addHTMLOutput(undefined, analysisEl);
    }

    function testAnalysisViewWithSingleSliceCategory() {
      var selection = createSelectionWithSingleSlice(true);

      var analysisEl = new TimelineAnalysisView();
      analysisEl.selection = selection;
      this.addHTMLOutput(undefined, analysisEl);
    }

    function testAnalysisViewWithMultipleSlices() {
      var selection = createSelectionWithTwoSlices();

      var analysisEl = new TimelineAnalysisView();
      analysisEl.selection = selection;
      this.addHTMLOutput(undefined, analysisEl);
    }

    function testAnalysisViewWithMultipleSlicesSameTitle() {
      var selection = createSelectionWithTwoSlicesSameTitle();

      var analysisEl = new TimelineAnalysisView();
      analysisEl.selection = selection;
      this.addHTMLOutput(undefined, analysisEl);
    }

    function testAnalysisViewWithSingleCounterWithTwoSeries() {
      var selection = createSelectionWithTwoSeriesSingleCounter();

      var analysisEl = new TimelineAnalysisView();
      analysisEl.selection = selection;
      this.addHTMLOutput(undefined, analysisEl);
    }

    function testAnalysisViewWithTwoCountersWithTwoSeries() {
      var selection = createSelectionWithTwoSeriesTwoCounters();

      var analysisEl = new TimelineAnalysisView();
      analysisEl.selection = selection;
      this.addHTMLOutput(undefined, analysisEl);
    }

    function testAnalysisViewWithSingleSliceSingleCounter() {
      var selection = createSelectionWithSingleSliceSingleCounter();

      var analysisEl = new TimelineAnalysisView();
      analysisEl.selection = selection;
      this.addHTMLOutput(undefined, analysisEl);
    }

    function testSelectionWithNormallyDistributedSamples() {
      var numSlices = 1;
      var selection = createSelectionWithNormallyDistributedSamples(numSlices);

      var analysisEl = new TimelineAnalysisView();
      analysisEl.selection = selection;
      this.addHTMLOutput(undefined, analysisEl);
    }

    function StubAnalysisResults() {
      this.tables = [];
    }
    StubAnalysisResults.prototype = {
      __proto__: Object.protoype,

      appendTable: function(parent, className) {
        var table = {
          className: className,
          rows: []
        };
        table.className = className;
        this.tables.push(table);
        return table;
      },

      appendTableHeader: function(table, label) {
        if (table.tableHeader)
          throw new Error('Only one summary header allowed.');
        table.tableHeader = label;
      },

      appendSummaryRow: function(table, label, opt_text) {
        table.rows.push({label: label,
                         text: opt_text});
      },

      appendSpacingRow: function(table) {
        table.rows.push({spacing: true});
      },

      appendSummaryRowTime: function(table, label, time) {
        table.rows.push({label: label,
                         time: time});
      },

      appendDataRow: function(table, label, duration, occurences, details) {
        table.rows.push({label: label,
                         duration: duration,
                         occurences: occurences,
                         details: details});
      }
    };

    function testAnalyzeSelectionWithSingleSlice() {
      var selection = createSelectionWithSingleSlice();

      var results = new StubAnalysisResults();
      tracing.analyzeSelection_(results, selection);
      assertEquals(1, results.tables.length);
      var table = results.tables[0];
      assertEquals('Selected slice:', table.tableHeader);
      assertEquals(3, table.rows.length);

      assertEquals('b', table.rows[0].text);
      assertEquals(0, table.rows[1].time);
      assertAlmostEquals(0.002, table.rows[2].time);
    }

    function testAnalyzeSelectionWithFalsyArgs() {
      var model = new TimelineModel();
      var t53 = model.getOrCreateProcess(52).getOrCreateThread(53);
      var slice = newSliceNamed('b', 0, 0.002);
      slice.args.bar = 0;
      slice.args.foo = false;
      t53.pushSlice(slice);
      var t53track = new TimelineThreadTrack();
      t53track.thread = t53;
      var selection = new TimelineSelection();
      t53track.addAllObjectsMatchingFilterToSelection(
        new TimelineTitleFilter('b'), selection);
      assertEquals(1, selection.length);

      var analysisEl = new TimelineAnalysisView();
      analysisEl.selection = selection;
      this.addHTMLOutput(undefined, analysisEl);
      var rows = analysisEl.querySelectorAll('tr');
      assertEquals(rows.length, 7);
      assertEquals(' bar', rows[5].children[0].textContent);
      assertEquals('0', rows[5].children[1].textContent);
      assertEquals(' foo', rows[6].children[0].textContent);
      assertEquals('false', rows[6].children[1].textContent);
    }

    function testAnalyzeSelectionWithSingleSliceCategory() {
      var selection = createSelectionWithSingleSlice(true);

      var results = new StubAnalysisResults();
      tracing.analyzeSelection_(results, selection);
      assertEquals(1, results.tables.length);
      var table = results.tables[0];
      assertEquals('Selected slice:', table.tableHeader);
      assertEquals(4, table.rows.length);

      assertEquals('b', table.rows[0].text);
      assertEquals('foo', table.rows[1].text);
      assertEquals(0, table.rows[2].time);
      assertAlmostEquals(0.002, table.rows[3].time);
    }

    function testAnalyzeSelectionWithTwoSlices() {
      var selection = createSelectionWithTwoSlices();

      var results = new StubAnalysisResults();
      tracing.analyzeSelection_(results, selection);
      assertEquals(1, results.tables.length);
      var table = results.tables[0];
      assertEquals('Slices:', table.tableHeader);
      assertEquals(6, table.rows.length);

      assertEquals('a', table.rows[0].label);
      assertEquals(1, table.rows[0].occurences);
      assertAlmostEquals(0.04, table.rows[0].duration);
      assertEquals('aa', table.rows[1].label);
      assertEquals(1, table.rows[1].occurences);
      assertAlmostEquals(0.06, table.rows[1].duration);
      assertEquals('*Totals', table.rows[2].label);
      assertEquals(2, table.rows[2].occurences);
      assertAlmostEquals(0.1, table.rows[2].duration);

      assertEquals('Selection start', table.rows[4].label);
      assertAlmostEquals(0, table.rows[4].time);

      assertEquals('Selection extent', table.rows[5].label);
      assertAlmostEquals(0.18, table.rows[5].time);
    }

    function testAnalyzeSelectionWithTwoSlicesSameTitle() {
      var selection = createSelectionWithTwoSlicesSameTitle();

      var results = new StubAnalysisResults();
      tracing.analyzeSelection_(results, selection);
      assertEquals(1, results.tables.length);
      var table = results.tables[0];

      assertEquals('Slices:', table.tableHeader);
      assertEquals(5, table.rows.length);

      assertEquals('c', table.rows[0].label);
      assertEquals('2', table.rows[0].occurences);
      assertAlmostEquals(0.04, table.rows[0].details.min);
      assertAlmostEquals(0.05, table.rows[0].details.avg);
      assertAlmostEquals(0.06, table.rows[0].details.max);
      assertAlmostEquals(0.1, table.rows[0].duration);
      assertEquals('*Totals', table.rows[1].label);
      assertAlmostEquals(0.1, table.rows[1].duration);
      assertEquals('Selection start', table.rows[3].label);
      assertAlmostEquals(0, table.rows[3].time);
      assertEquals('Selection extent', table.rows[4].label);
      assertAlmostEquals(0.18, table.rows[4].time);
    }

    function testAnalyzeSelectionWithSingleCounter() {
      var selection = createSelectionWithCounters(1);

      var results = new StubAnalysisResults();
      tracing.analyzeSelection_(results, selection);
      assertEquals(1, results.tables.length);
      var table = results.tables[0];
      assertEquals('Selected counter:', table.tableHeader);
      assertEquals(3, table.rows.length);

      assertEquals('Title', table.rows[0].label);
      assertEquals('Timestamp', table.rows[1].label);
      assertEquals('value', table.rows[2].label);
      assertEquals(10, table.rows[2].text);
    }

    function testAnalyzeSelectionWithBasicTwoSeriesTwoCounters() {
      var selection = createSelectionWithTwoSeriesTwoCounters();

      var results = new StubAnalysisResults();
      tracing.analyzeSelection_(results, selection);
      assertEquals(1, results.tables.length);
      var table = results.tables[0];
      assertEquals('Counters:', table.tableHeader);
      assertEquals(4, table.rows.length);

      assertEquals('ctr1: bytesallocated', table.rows[0].label);
      assertEquals('ctr1: bytesfree', table.rows[1].label);
      assertEquals('ctr2: bytesallocated', table.rows[2].label);
      assertEquals('ctr2: bytesfree', table.rows[3].label);
    }

    function testAnalyzeSelectionWithComplexSeriesTwoCounters() {
      var selection = createSelectionWithTwoCountersDiffSeriesDiffHits();

      var results = new StubAnalysisResults();
      tracing.analyzeSelection_(results, selection);
      assertEquals(1, results.tables.length);
      var table = results.tables[0];
      assertEquals('Counters:', table.tableHeader);
      assertEquals(3, table.rows.length);

      assertEquals('a: bytesallocated', table.rows[0].label);
      assertEquals('b: bytesallocated', table.rows[1].label);
      assertEquals('b: bytesfree', table.rows[2].label);
    }

    function testAnalyzeSelectionWithCounterAndSlices() {
      var selection = createSelectionWithSingleSliceSingleCounter();

      var results = new StubAnalysisResults();
      tracing.analyzeSelection_(results, selection);
      assertEquals(2, results.tables.length);
      var sliceTable = results.tables[0];
      var counterTable = results.tables[1];

      assertEquals('Selected slice:', sliceTable.tableHeader);
      assertEquals(3, sliceTable.rows.length);

      assertEquals('Selected counter:', counterTable.tableHeader);
      assertEquals(4, counterTable.rows.length);
    }

    function testAnalyzeSelectionWithNormallyDistributedSamples() {
      var numSlices = 2;
      var selection = createSelectionWithNormallyDistributedSamples(numSlices);

      var results = new StubAnalysisResults();
      tracing.analyzeSelection_(results, selection);
      assertEquals(1, results.tables.length);

      assertEquals('slice0', results.tables[0].rows[0].label);
      assertEquals(
          63, Math.round(results.tables[0].rows[0].details.frequency));
      assertEquals(
          16, Math.round(results.tables[0].rows[0].details.frequency_stddev));

      assertEquals('slice1', results.tables[0].rows[1].label);
      assertEquals(
          63, Math.round(results.tables[0].rows[1].details.frequency));
      assertEquals(
          16, Math.round(results.tables[0].rows[1].details.frequency_stddev));
    }
  </script>
</body>
</html>
