public List<MethodCounter/*!*/>/*!*/ GetProfile() {
var result = new List<MethodCounter>();
lock (_counters) {
// capture the current profile:
long[] newProfile = new long[_ProfileTicks.Length];
long[] total = Interlocked.Exchange(ref _ProfileTicks, newProfile);
for (int i = 0; i < _profiles.Count; i++) {
for (int j = 0; j < total.Length; j++) {
if (j < _profiles[i].Length) {
total[j] += _profiles[i][j];
}
}
}
foreach (var counter in _counters) {
string methodName = counter.Key;
string fileName = null;
int line = 0;
if (RubyStackTraceBuilder.TryParseRubyMethodName(ref methodName, ref fileName, ref line)) {
result.Add(new MethodCounter(methodName, fileName, line, total[counter.Value]));
}
}
}
return result;
}
}