lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [lucenenet] jeme commented on issue #346: Remove Debugging.AssertsEnabled
Date Sun, 18 Oct 2020 09:58:37 GMT

jeme commented on issue #346:
URL: https://github.com/apache/lucenenet/issues/346#issuecomment-711144397


   Just to throw a sort of Nuclear option into the mix, It would to some degree be possible
to utilize AOP to actually inject code directly into the existing code at runtime. It has
a small performance penalty (But I have not tested it in comparison to the design there is
already in place, only made a Clean vs. AOP'ed method test), but for at least some of the
examples here it would not be noticeable.
   
   It is a bit of a challenge for methods where the use of "Debugging" does not happen right
at the beginning or the end, something that certainly has multiple solutions, but finding
one where we can safely say it's "not just there" for testing could be difficult in some cases.
   
   If we take a really simple example with harmony:
   ----
   ```
       public class TargetClass
       {
           public void TargetMethod()
           {
               long i = 1;
               while (i < int.MaxValue)
                   i += i;
           }
       }
   
       [HarmonyPatch(typeof(TargetClass))]
       [HarmonyPatch(nameof(TargetClass.TargetMethod))]
       public class Patch
       {
           public static void Prefix()
           {
               // Noop, just the cost of attaching it is tested.
           }
       }
   ```
   ----
   
   ``` ini
   
   BenchmarkDotNet=v0.12.1, OS=Windows 10.0.18362.1082 (1903/May2019Update/19H1)
   Intel Core i9-7900X CPU 3.30GHz (Kaby Lake), 1 CPU, 20 logical and 10 physical cores
   .NET Core SDK=5.0.100-rc.1.20452.10
     [Host]     : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203), X64 RyuJIT
     DefaultJob : .NET Core 3.1.9 (CoreCLR 4.700.20.47201, CoreFX 4.700.20.47203), X64 RyuJIT
   
   
   ```
   |    Method |      Mean |     Error |    StdDev |
   |---------- |----------:|----------:|----------:|
   | BeforeAOP |  9.595 ns | 0.0639 ns | 0.0598 ns |
   |  AfterAOP | 10.533 ns | 0.1100 ns | 0.1029 ns |
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message