Better access to symbol scope dictionary from profiler.

This commit is contained in:
Adrian Conlon 2024-07-08 10:13:13 +01:00
parent e73d7a52b2
commit f2b6fb1660

View File

@ -119,18 +119,18 @@
private void Processor_ExecutedInstruction(object? sender, EventArgs e) private void Processor_ExecutedInstruction(object? sender, EventArgs e)
{ {
this.TotalCycleCount += this.processor.Cycles; var cycles = this.processor.Cycles;
this.TotalCycleCount += cycles;
this.addressProfiles[this.executingAddress] += this.processor.Cycles; this.addressProfiles[this.executingAddress] += cycles;
var scope = this.symbols.LookupScopeByAddress(this.executingAddress); var scope = this.symbols.LookupScopeByAddress(this.executingAddress);
if (scope != null) if (scope != null)
{ {
var id = scope.ID; var id = scope.ID;
if (!this.scopeCycles.TryAdd(id, 0)) // Current will be initialised to zero, if absent
{ _ = this.scopeCycles.TryGetValue(id, out var current);
this.scopeCycles[id] += this.processor.Cycles; this.scopeCycles[id] = current + cycles;
}
} }
} }