public void When_Running_On_NET50_Then_Counts_Of_Methods_Are_Recorded() { // arrage var methodsJittedPrevious = MetricProducer.MethodsJittedTotal.Value; var bytesJittedPrevious = MetricProducer.BytesJitted.Value; // act RuntimeEventHelper.CompileMethods(() => 1, 100); Assert.That(MetricProducer.BytesJitted, Is.Not.Null); Assert.That(MetricProducer.MethodsJittedTotal, Is.Not.Null); Assert.That(() => MetricProducer.BytesJitted.Value, Is.GreaterThan(bytesJittedPrevious).After(2_000, 10)); Assert.That(() => MetricProducer.MethodsJittedTotal.Value, Is.GreaterThan(methodsJittedPrevious + 100).After(2_000, 10)); }
public void When_many_methods_are_jitted_then_their_compilation_is_measured() { // arrange var methodsJitted = MetricProducer.MethodsJittedTotal.Labels("true").Value; var methodsJittedSeconds = MetricProducer.MethodsJittedSecondsTotal.Labels("true").Value; // act var sp = Stopwatch.StartNew(); RuntimeEventHelper.CompileMethods(() => 1, 100); sp.Stop(); // assert Assert.That(() => MetricProducer.MethodsJittedTotal.Labels("true").Value, Is.GreaterThanOrEqualTo(methodsJitted + 20).After(100, 10)); Assert.That(MetricProducer.MethodsJittedSecondsTotal.Labels("true").Value, Is.GreaterThan(methodsJittedSeconds + sp.Elapsed.TotalSeconds).Within(0.1)); }