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

Side by Side Diff: pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/profile.dart

Issue 2874813002: Support configuring DDC runtime settings before the application starts and normalize API for config… (Closed)
Patch Set: Support configuring DDC runtime settings before the application starts and normalize API for config… Created 3 years, 7 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 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// This file supports profiling dynamic calls. 5 /// This file supports profiling dynamic calls.
6 part of dart._runtime; 6 part of dart._runtime;
7 7
8 class _MethodStats { 8 class _MethodStats {
9 final String typeName; 9 final String typeName;
10 final String frame; 10 final String frame;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 var stats = callMethodStats[key]; 107 var stats = callMethodStats[key];
108 ret.add([stats.typeName, stats.frame, stats.count.round()]); 108 ret.add([stats.typeName, stats.frame, stats.count.round()]);
109 } 109 }
110 return ret; 110 return ret;
111 } 111 }
112 112
113 clearDynamicStats() { 113 clearDynamicStats() {
114 _callMethodRecords.clear(); 114 _callMethodRecords.clear();
115 } 115 }
116 116
117 bool trackProfile = JS('bool', 'dart.global.trackDdcProfile'); 117 bool _trackProfile = false;
118
119 void trackProfile(bool flag) {
120 _trackProfile = flag;
121 }
118 122
119 _trackCall(obj) { 123 _trackCall(obj) {
120 if (JS('bool', '!#', trackProfile)) return; 124 if (JS('bool', '!#', trackProfile)) return;
121 int index = -1; 125 int index = -1;
122 _totalCallRecords++; 126 _totalCallRecords++;
123 if (_callMethodRecords.length == _callRecordSampleSize) { 127 if (_callMethodRecords.length == _callRecordSampleSize) {
124 // Ensure that each sample has an equal 128 // Ensure that each sample has an equal
125 // _callRecordSampleSize / _totalCallRecords chance of inclusion 129 // _callRecordSampleSize / _totalCallRecords chance of inclusion
126 // by choosing to include the new record in the sample the with the 130 // by choosing to include the new record in the sample the with the
127 // appropriate probability randomly evicting one of the existing records. 131 // appropriate probability randomly evicting one of the existing records.
128 // Unfortunately we can't use the excellent Random.nextInt method defined 132 // Unfortunately we can't use the excellent Random.nextInt method defined
129 // by Dart from within this library. 133 // by Dart from within this library.
130 index = JS('int', 'Math.floor(Math.random() * #)', _totalCallRecords); 134 index = JS('int', 'Math.floor(Math.random() * #)', _totalCallRecords);
131 if (index >= _callMethodRecords.length) return; // don't sample 135 if (index >= _callMethodRecords.length) return; // don't sample
132 } 136 }
133 var record = 137 var record =
134 new _CallMethodRecord(JS('', 'new Error()'), getReifiedType(obj)); 138 new _CallMethodRecord(JS('', 'new Error()'), getReifiedType(obj));
135 if (index == -1) { 139 if (index == -1) {
136 _callMethodRecords.add(record); 140 _callMethodRecords.add(record);
137 } else { 141 } else {
138 _callMethodRecords[index] = record; 142 _callMethodRecords[index] = record;
139 } 143 }
140 } 144 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698