summaryrefslogtreecommitdiff
path: root/chromium/third_party/catapult/tracing/tracing/ui/analysis/frame_power_usage_chart_perf_test.html
blob: caf4601f33c71e99243ff89f05d9ff309f803a84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!DOCTYPE html>
<!--
Copyright 2016 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.
-->

<link rel="import" href="/tracing/model/event_set.html">
<link rel="import" href="/tracing/model/model.html">
<link rel="import" href="/tracing/model/power_sample.html">
<link rel="import" href="/tracing/model/power_series.html">
<link rel="import" href="/tracing/ui/analysis/frame_power_usage_chart.html">

<script>
'use strict';

tr.b.unittest.testSuite(function() {
  function instantiateManyFrames() {
    const model = new tr.Model();
    const numFrames = 200;
    const samplesPerFrame = 200;

    // Set up the test data.
    const series = new tr.model.PowerSeries(model.device);
    const vsyncTimestamps = [];
    for (let i = 0; i < numFrames; i++) {
      vsyncTimestamps.push(i * samplesPerFrame);
      for (let j = 0; j < samplesPerFrame; j++) {
        series.addPowerSample(vsyncTimestamps[i] + j, j);
      }
    }
    const samples = series.samples;

    // Display the chart.
    const chart = document.createElement('tr-ui-a-frame-power-usage-chart');
    chart.setData(new tr.model.EventSet(samples), vsyncTimestamps);
    this.addHTMLOutput(chart);
  }

  timedPerfTest('frame_power_usage_chart', instantiateManyFrames, {
    iterations: 1
  });
});
</script>