| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <!-- | 2 <!-- |
| 3 Copyright 2016 The Chromium Authors. All rights reserved. | 3 Copyright 2016 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/core/test_utils.html"> | 8 <link rel="import" href="/tracing/core/test_utils.html"> |
| 9 <link rel="import" href="/tracing/extras/importer/trace_event_importer.html"> | 9 <link rel="import" href="/tracing/extras/importer/trace_event_importer.html"> |
| 10 <link rel="import" href="/tracing/metrics/cpu_process_metric.html"> | 10 <link rel="import" href="/tracing/metrics/cpu_process_metric.html"> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 }, | 48 }, |
| 49 'pid': 52, 'ts': '2226221225693.658', tid: 53, | 49 'pid': 52, 'ts': '2226221225693.658', tid: 53, |
| 50 'tid': undefined, 'ph': 'O', 'local': true, 'id': '0x1000' | 50 'tid': undefined, 'ph': 'O', 'local': true, 'id': '0x1000' |
| 51 } | 51 } |
| 52 ]; | 52 ]; |
| 53 tr.metrics.sh.cpuProcessMetric(values, makeModel(events)); | 53 tr.metrics.sh.cpuProcessMetric(values, makeModel(events)); |
| 54 assert.lengthOf(values.getValuesNamed('cpu:percent:chrome'), 1); | 54 assert.lengthOf(values.getValuesNamed('cpu:percent:chrome'), 1); |
| 55 assert.lengthOf(values.getValuesNamed('cpu:percent:crudd'), 1); | 55 assert.lengthOf(values.getValuesNamed('cpu:percent:crudd'), 1); |
| 56 var chromeValue = values.getValuesNamed('cpu:percent:chrome')[0]; | 56 var chromeValue = values.getValuesNamed('cpu:percent:chrome')[0]; |
| 57 var chromeStatistics = chromeValue.numeric.running; | 57 var chromeStatistics = chromeValue.running; |
| 58 assert.strictEqual(chromeStatistics.count, 1); | 58 assert.strictEqual(chromeStatistics.count, 1); |
| 59 assert.closeTo(chromeStatistics.mean, 0.011, 1e-5); | 59 assert.closeTo(chromeStatistics.mean, 0.011, 1e-5); |
| 60 assert.closeTo(chromeStatistics.max, 0.011, 1e-5); | 60 assert.closeTo(chromeStatistics.max, 0.011, 1e-5); |
| 61 assert.instanceOf(chromeValue.diagnostics.get('paths'), tr.v.d.Generic); | 61 assert.instanceOf(chromeValue.diagnostics.get('paths'), tr.v.d.Generic); |
| 62 assert.lengthOf(chromeValue.diagnostics.get('paths').value, 1); | 62 assert.lengthOf(chromeValue.diagnostics.get('paths').value, 1); |
| 63 assert.strictEqual(chromeValue.diagnostics.get('paths').value[0], | 63 assert.strictEqual(chromeValue.diagnostics.get('paths').value[0], |
| 64 '/opt/chrome/chrome'); | 64 '/opt/chrome/chrome'); |
| 65 }); | 65 }); |
| 66 | 66 |
| 67 test('cpuProcessMetric_multipleSnapshots', function() { | 67 test('cpuProcessMetric_multipleSnapshots', function() { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 }, | 100 }, |
| 101 'pid': 52, 'ts': '2226222262064.4473', tid: 53, | 101 'pid': 52, 'ts': '2226222262064.4473', tid: 53, |
| 102 'tid': undefined, 'ph': 'O', 'local': true, 'id': '0x1000' | 102 'tid': undefined, 'ph': 'O', 'local': true, 'id': '0x1000' |
| 103 } | 103 } |
| 104 ]; | 104 ]; |
| 105 tr.metrics.sh.cpuProcessMetric(values, makeModel(events)); | 105 tr.metrics.sh.cpuProcessMetric(values, makeModel(events)); |
| 106 assert.lengthOf(values.getValuesNamed('cpu:percent:chrome'), 1); | 106 assert.lengthOf(values.getValuesNamed('cpu:percent:chrome'), 1); |
| 107 assert.lengthOf(values.getValuesNamed('cpu:percent:crudd'), 1); | 107 assert.lengthOf(values.getValuesNamed('cpu:percent:crudd'), 1); |
| 108 assert.lengthOf(values.getValuesNamed('cpu:percent:mnp_logger'), 1); | 108 assert.lengthOf(values.getValuesNamed('cpu:percent:mnp_logger'), 1); |
| 109 var chromeValue = values.getValuesNamed('cpu:percent:chrome')[0]; | 109 var chromeValue = values.getValuesNamed('cpu:percent:chrome')[0]; |
| 110 var chromeStatistics = chromeValue.numeric.running; | 110 var chromeStatistics = chromeValue.running; |
| 111 assert.strictEqual(chromeStatistics.count, 2); | 111 assert.strictEqual(chromeStatistics.count, 2); |
| 112 assert.closeTo(chromeStatistics.mean, 0.0075, 1e-5); | 112 assert.closeTo(chromeStatistics.mean, 0.0075, 1e-5); |
| 113 assert.strictEqual(chromeStatistics.max, 0.008); | 113 assert.strictEqual(chromeStatistics.max, 0.008); |
| 114 assert.instanceOf(chromeValue.diagnostics.get('paths'), tr.v.d.Generic); | 114 assert.instanceOf(chromeValue.diagnostics.get('paths'), tr.v.d.Generic); |
| 115 assert.lengthOf(chromeValue.diagnostics.get('paths').value, 2); | 115 assert.lengthOf(chromeValue.diagnostics.get('paths').value, 2); |
| 116 assert.strictEqual(chromeValue.diagnostics.get('paths').value[0], | 116 assert.strictEqual(chromeValue.diagnostics.get('paths').value[0], |
| 117 '/opt/chrome/chrome'); | 117 '/opt/chrome/chrome'); |
| 118 | 118 |
| 119 }); | 119 }); |
| 120 }); | 120 }); |
| 121 </script> | 121 </script> |
| OLD | NEW |