/// <summary> /// Initializes a new instance of the <see cref="PerfCounterRunInvoker"/> class. /// </summary> /// <param name="invoker">The test invoker.</param> /// <param name="attribute">The <see cref="PerfCounterAttribute"/> tagging the test method.</param> public PerfCounterRunInvoker(IRunInvoker invoker, PerfCounterAttribute attribute) : base(invoker) { this.attribute = attribute; this.counter = new PerformanceCounter(); this.counter.CategoryName = attribute.CategoryName; this.counter.CounterName = attribute.CounterName; Process currentProcesss = Process.GetCurrentProcess(); if (attribute.InstanceName != null) { this.counter.InstanceName = attribute.InstanceName; } else { this.counter.InstanceName = currentProcesss.ProcessName; } if (attribute.MachineName != null) { this.counter.MachineName = attribute.MachineName; } else { this.counter.MachineName = currentProcesss.MachineName; } }
public PerfCounterRunInvoker(IRunInvoker invoker, PerfCounterAttribute attribute) : base(invoker) { this.attribute = attribute; this.counter = new PerformanceCounter(); this.counter.CategoryName = attribute.CategoryName; this.counter.CounterName = attribute.CounterName; Process currentProcesss = Process.GetCurrentProcess(); if (attribute.InstanceName != null) this.counter.InstanceName = attribute.InstanceName; else this.counter.InstanceName = currentProcesss.ProcessName; if (attribute.MachineName != null) this.counter.MachineName = attribute.MachineName; else this.counter.MachineName = currentProcesss.MachineName; }