Created
July 14, 2021 22:47
-
-
Save EgorBo/24f7f20035bcb00ecc9aaac7a49e9a87 to your computer and use it in GitHub Desktop.
Program.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Diagnostics; | |
| using System.Runtime.CompilerServices; | |
| public static class Tests | |
| { | |
| static void Main() | |
| { | |
| var ff = new ClassBFactoryFactory(); | |
| var sw = Stopwatch.StartNew(); | |
| for (int iter = 0; iter < 10; iter++) | |
| { | |
| sw.Restart(); | |
| for (int i = 0; i < 10000000; i++) | |
| { | |
| Test(ff); | |
| Test(ff); | |
| Test(ff); | |
| Test(ff); | |
| } | |
| sw.Stop(); | |
| Console.WriteLine(sw.ElapsedMilliseconds); | |
| } | |
| } | |
| [MethodImpl(MethodImplOptions.NoInlining)] | |
| static long Test(ClassAFactoryFactory ff) | |
| { | |
| if (ff != null) | |
| { | |
| var f = ff.GetClassAFactory(); | |
| if (f != null) | |
| { | |
| ClassA classA = f.GetA(); | |
| if (classA != null) | |
| { | |
| // GetValue() call here is correctly devirtualized to idiv | |
| // in FullPGO mode. | |
| return classA.GetValue(); | |
| } | |
| } | |
| } | |
| return 0; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment