Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: trace_processor/experimental/mappers/trace_stats.html

Issue 2293533002: Refactor NumericBuilder to HistogramBinBoundaries. (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright 2015 The Chromium Authors. All rights reserved. 3 Copyright 2015 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import" href="/tracing/base/range.html"> 8 <link rel="import" href="/tracing/base/range.html">
9 <link rel="import" href="/tracing/mre/function_handle.html"> 9 <link rel="import" href="/tracing/mre/function_handle.html">
10 <link rel="import" href="/tracing/value/histogram.html"> 10 <link rel="import" href="/tracing/value/histogram.html">
11 <link rel="import" href="/tracing/value/unit.html"> 11 <link rel="import" href="/tracing/value/unit.html">
12 12
13 <script> 13 <script>
14 'use strict'; 14 'use strict';
15 15
16 tr.exportTo('pi.m', function() { 16 tr.exportTo('pi.m', function() {
17 var COUNT_NUMERIC_BUILDER = tr.v.NumericBuilder.createLinear( 17 var COUNT_BOUNDARIES = tr.v.HistogramBinBoundaries.createLinear(0, 5e4, 20);
18 tr.v.Unit.byName.unitlessNumber, tr.b.Range.fromExplicitRange(0, 50000),
19 20);
20 18
21 function traceStatsFunction(result, model) { 19 function traceStatsFunction(result, model) {
22 var canonicalUrl = model.canonicalUrl; 20 var canonicalUrl = model.canonicalUrl;
23 var eventCount = 0; 21 var eventCount = 0;
24 var firstTime = Number.MAX_VALUE; 22 var firstTime = Number.MAX_VALUE;
25 var lastTime = 0; 23 var lastTime = 0;
26 var categories = {}; 24 var categories = {};
27 25
28 var seconds_counts = {}; 26 var seconds_counts = {};
29 for (var event of model.getDescendantEvents()) { 27 for (var event of model.getDescendantEvents()) {
(...skipping 10 matching lines...) Expand all
40 38
41 categories[event.category]++; 39 categories[event.category]++;
42 40
43 var second = Math.round(event.start / 1000); 41 var second = Math.round(event.start / 1000);
44 if (seconds_counts[second] === undefined) 42 if (seconds_counts[second] === undefined)
45 seconds_counts[second] = 0; 43 seconds_counts[second] = 0;
46 44
47 seconds_counts[second]++; 45 seconds_counts[second]++;
48 } 46 }
49 47
50 var histogram = COUNT_NUMERIC_BUILDER.build(); 48 var histogram = new tr.v.Histogram(
49 tr.v.Unit.byName.count, COUNT_BOUNDARIES);
51 50
52 for (var second in seconds_counts) 51 for (var second in seconds_counts)
53 histogram.add(seconds_counts[second]); 52 histogram.add(seconds_counts[second]);
54 53
55 var stats = { 54 var stats = {
56 totalEvents: eventCount, 55 totalEvents: eventCount,
57 firstTimeInMS: firstTime, 56 firstTimeInMS: firstTime,
58 lastTimeInMS: lastTime, 57 lastTimeInMS: lastTime,
59 durationInMS: lastTime - firstTime, 58 durationInMS: lastTime - firstTime,
60 eventsPerSecond: eventCount / (lastTime - firstTime) * 1000, 59 eventsPerSecond: eventCount / (lastTime - firstTime) * 1000,
61 categories: categories, 60 categories: categories,
62 events_seconds: histogram.asDict() 61 events_seconds: histogram.asDict()
63 }; 62 };
64 63
65 result.addPair('stats', stats); 64 result.addPair('stats', stats);
66 } 65 }
67 66
68 tr.mre.FunctionRegistry.register(traceStatsFunction); 67 tr.mre.FunctionRegistry.register(traceStatsFunction);
69 68
70 //Exporting for tests. 69 //Exporting for tests.
71 return { 70 return {
72 traceStatsFunctionForTest: traceStatsFunction 71 traceStatsFunctionForTest: traceStatsFunction
73 }; 72 };
74 }); 73 });
75 </script> 74 </script>
OLDNEW
« no previous file with comments | « trace_processor/experimental/mappers/task_info_map_function.html ('k') | tracing/tracing/metrics/blink/gc_metric.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698