| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <!-- | |
| 3 Copyright (c) 2015 The Chromium Authors. All rights reserved. | |
| 4 Use of this source code is governed by a BSD-style license that can be | |
| 5 found in the LICENSE file. | |
| 6 --> | |
| 7 | |
| 8 <link rel="import" href="/perf_insights/mappers/task_info_map_function.html"> | |
| 9 <link rel="import" href="/perf_insights/mre/mre_result.html"> | |
| 10 <link rel="import" href="/tracing/base/iteration_helpers.html"> | |
| 11 <link rel="import" href="/tracing/core/test_utils.html"> | |
| 12 <link rel="import" href="/tracing/value/numeric.html"> | |
| 13 | |
| 14 <script> | |
| 15 'use strict'; | |
| 16 | |
| 17 tr.b.unittest.testSuite(function() { | |
| 18 var test_utils = tr.c.TestUtils; | |
| 19 | |
| 20 test('taskInfoMapFunctionTest', function() { | |
| 21 var m = test_utils.newModel(function(m) { | |
| 22 var p1 = m.getOrCreateProcess(1); | |
| 23 p1.name = 'Process'; | |
| 24 var t2 = p1.getOrCreateThread(2); | |
| 25 t2.name = 'CrBrowserMain'; // To identify as browser process. | |
| 26 // t2_s0 is not a top-level, no incoming flow. | |
| 27 var t2_s0 = test_utils.newSliceEx( | |
| 28 { start: 0, duration: 9.7, cpuStart: 0, cpuDuration: 5.3}); | |
| 29 // t2_s1 is not a top-level, no incoming flow. | |
| 30 var t2_s1 = test_utils.newSliceEx( | |
| 31 { start: 11, duration: 20.1, cpuStart: 11, cpuDuration: 8.9 }); | |
| 32 // t2_s2 is a top-level slice: f2 flows into it. | |
| 33 var t2_s2 = test_utils.newSliceEx( | |
| 34 { start: 15, duration: 10.4, cpuStart: 15, cpuDuration: 3.0 }); | |
| 35 // t2_s3 is not a top-level slice because it's a child of t2_s2. | |
| 36 var t2_s3 = test_utils.newSliceEx( | |
| 37 { start: 17, duration: 2.4, cpuStart: 17, cpuDuration: 1.1 }); | |
| 38 t2.sliceGroup.pushSlice(t2_s0); | |
| 39 t2.sliceGroup.pushSlice(t2_s1); | |
| 40 t2.sliceGroup.pushSlice(t2_s2); | |
| 41 t2.sliceGroup.pushSlice(t2_s3); | |
| 42 var f1 = test_utils.newFlowEventEx({ | |
| 43 start: 0, duration: 18.1, startSlice: t2_s0, endSlice: t2_s3 | |
| 44 }); | |
| 45 var f2 = test_utils.newFlowEventEx({ | |
| 46 start: 9, duration: 7.2, startSlice: t2_s0, endSlice: t2_s2 | |
| 47 }); | |
| 48 m.flowEvents.push(f1); | |
| 49 m.flowEvents.push(f2); | |
| 50 }); | |
| 51 | |
| 52 var result = new pi.mre.MreResult(); | |
| 53 pi.m.taskInfoMapFunctionForTest(result, m); | |
| 54 | |
| 55 assert.equal(tr.b.dictionaryLength(result.pairs), 3); | |
| 56 var time_spent_in_queue = result.pairs.time_spent_in_queue; | |
| 57 assert.equal(tr.b.dictionaryLength(time_spent_in_queue.Browser), 1); | |
| 58 var histogram = tr.v.Numeric.fromDict( | |
| 59 time_spent_in_queue['Browser']['CrBrowserMain']); | |
| 60 assert.equal(histogram.getBinForValue(7.2).count, 1); | |
| 61 assert.equal(histogram.getBinForValue(18.1).count, 1); | |
| 62 var time_spent_in_top_level_task = ( | |
| 63 result.pairs.time_spent_in_top_level_task); | |
| 64 assert.equal(tr.b.dictionaryLength( | |
| 65 time_spent_in_top_level_task['Browser']), 1); | |
| 66 histogram = tr.v.Numeric.fromDict( | |
| 67 time_spent_in_top_level_task['Browser']['CrBrowserMain']); | |
| 68 assert.equal(histogram.getBinForValue(10.4).count, 1); | |
| 69 var cpu_time_spent_in_top_level_task = ( | |
| 70 result.pairs.cpu_time_spent_in_top_level_task); | |
| 71 assert.equal(tr.b.dictionaryLength( | |
| 72 cpu_time_spent_in_top_level_task['Browser']), 1); | |
| 73 histogram = tr.v.Numeric.fromDict( | |
| 74 cpu_time_spent_in_top_level_task['Browser']['CrBrowserMain']); | |
| 75 assert.equal(histogram.getBinForValue(3.0).count, 1); | |
| 76 }); | |
| 77 }); | |
| 78 | |
| 79 </script> | |
| OLD | NEW |