private void Start(DiagnoserActionParameters parameters) { var counters = benchmarkToCounters[parameters.BenchmarkCase] = parameters.Config .GetHardwareCounters() .Select(counter => HardwareCounters.FromCounter(counter, config.IntervalSelectors.TryGetValue(counter, out var selector) ? selector : GetInterval)) .ToArray(); if (counters.Any()) // we need to enable the counters before starting the kernel session { HardwareCounters.Enable(counters); } try { kernelSession = new KernelSession(parameters, config, CreationTime).EnableProviders(); if (config.CreateHeapSession) { heapSession = new HeapSession(parameters, config, CreationTime).EnableProviders(); } userSession = new UserSession(parameters, config, CreationTime).EnableProviders(); } catch (Exception) { userSession?.Dispose(); heapSession?.Dispose(); kernelSession?.Dispose(); throw; } }
protected override PmcStats GetInitializedStats(DiagnoserActionParameters parameters) { var stats = new PmcStats( parameters.Config.GetHardwareCounters().ToArray(), counter => HardwareCounters.FromCounter(counter, info => info.MinInterval)); // for this diagnoser we want the smallest interval to have best possible precision HardwareCounters.Enable(stats.Counters.Values); return(stats); }