Created
January 22, 2017 00:45
-
-
Save jkotas/9c492e62c59cb5e7220daeed587d254a to your computer and use it in GitHub Desktop.
Lazy<T> startup
This file contains 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; | |
class MyG<T,U> | |
{ | |
static Lazy<MyG<T,U>> s_lazy = new Lazy<MyG<T,U>>(); | |
public static void foo(int depth) | |
{ | |
if (s_lazy.IsValueCreated) return; | |
var dummy = s_lazy.Value; | |
if (depth-- == 0) return; | |
MyG<U,T>.foo(depth); | |
MyG<MyG<T,U>,T>.foo(depth); | |
MyG<MyG<T,U>,U>.foo(depth); | |
MyG<T,MyG<T,U>>.foo(depth); | |
MyG<U,MyG<T,U>>.foo(depth); | |
} | |
} | |
class My | |
{ | |
static void Main() | |
{ | |
int start = Environment.TickCount; | |
MyG<string,int>.foo(7); | |
int end = Environment.TickCount; | |
Console.WriteLine((end-start).ToString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment