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

Side by Side Diff: tools/perf/metrics/system_memory.py

Issue 385213002: Update system_memory to use results.AddValue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from metrics import memory 5 from metrics import memory
6 from metrics import Metric 6 from metrics import Metric
7 from telemetry.value import scalar
8
7 9
8 class SystemMemoryMetric(Metric): 10 class SystemMemoryMetric(Metric):
9 """SystemMemoryMetric gathers system memory statistic. 11 """SystemMemoryMetric gathers system memory statistic.
10 12
11 This metric collects system memory stats per test. It reports the difference 13 This metric collects system memory stats per test. It reports the difference
12 (delta) in system memory starts from the start of the test to the end of it. 14 (delta) in system memory starts from the start of the test to the end of it.
13 """ 15 """
14 16
15 def __init__(self, browser): 17 def __init__(self, browser):
16 super(SystemMemoryMetric, self).__init__() 18 super(SystemMemoryMetric, self).__init__()
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 memory_stats = _SubtractMemoryStats(self._memory_stats_end, 54 memory_stats = _SubtractMemoryStats(self._memory_stats_end,
53 self._memory_stats_start) 55 self._memory_stats_start)
54 if not memory_stats['Browser']: 56 if not memory_stats['Browser']:
55 return 57 return
56 exclude_metrics = exclude_metrics or {} 58 exclude_metrics = exclude_metrics or {}
57 memory.AddResultsForProcesses(results, memory_stats, 59 memory.AddResultsForProcesses(results, memory_stats,
58 metric_trace_name=trace_name, chart_trace_name='delta', 60 metric_trace_name=trace_name, chart_trace_name='delta',
59 exclude_metrics=exclude_metrics) 61 exclude_metrics=exclude_metrics)
60 62
61 if 'SystemCommitCharge' not in exclude_metrics: 63 if 'SystemCommitCharge' not in exclude_metrics:
62 results.Add(trace_name or 'commit_charge', 'kb', 64 results.AddValue(scalar.ScalarValue(
63 memory_stats['SystemCommitCharge'], 65 results.current_page,
64 chart_name='commit_charge_delta', 66 'commit_charge_delta.%s' % (trace_name or 'commit_charge'), 'kb',
65 data_type='unimportant') 67 memory_stats['SystemCommitCharge'], important=False))
66 68
67 if 'ProcessCount' not in exclude_metrics: 69 if 'ProcessCount' not in exclude_metrics:
68 results.Add(trace_name or 'processes', 'count', 70 results.AddValue(scalar.ScalarValue(
69 memory_stats['ProcessCount'], 71 results.current_page,
70 chart_name='processes_delta', 72 'processes_delta.%s' % (trace_name or 'processes'), 'count',
71 data_type='unimportant') 73 memory_stats['ProcessCount'], important=False))
72 74
73 75
74 def _SubtractMemoryStats(end_memory_stats, start_memory_stats): 76 def _SubtractMemoryStats(end_memory_stats, start_memory_stats):
75 """Computes the difference in memory usage stats. 77 """Computes the difference in memory usage stats.
76 78
77 Each of the two stats arguments is a dict with the following format: 79 Each of the two stats arguments is a dict with the following format:
78 {'Browser': {metric: value, ...}, 80 {'Browser': {metric: value, ...},
79 'Renderer': {metric: value, ...}, 81 'Renderer': {metric: value, ...},
80 'Gpu': {metric: value, ...}, 82 'Gpu': {metric: value, ...},
81 'ProcessCount': value, 83 'ProcessCount': value,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 memory_stats[process_type] = end_process_memory - start_value 115 memory_stats[process_type] = end_process_memory - start_value
114 else: 116 else:
115 for metric in end_process_memory: 117 for metric in end_process_memory:
116 end_value = end_process_memory[metric] 118 end_value = end_process_memory[metric]
117 start_value = start_memory_stats[process_type][metric] or 0 119 start_value = start_memory_stats[process_type][metric] or 0
118 if 'Peak' in metric: 120 if 'Peak' in metric:
119 memory_stats[process_type][metric] = end_value 121 memory_stats[process_type][metric] = end_value
120 else: 122 else:
121 memory_stats[process_type][metric] = end_value - start_value 123 memory_stats[process_type][metric] = end_value - start_value
122 return memory_stats 124 return memory_stats
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698