Created
March 12, 2012 15:22
-
-
Save marek-safar/2022611 to your computer and use it in GitHub Desktop.
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; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ConsoleApplication5 | |
{ | |
interface IA | |
{ | |
void Method(); | |
} | |
struct S : IA | |
{ | |
public void Method() | |
{ | |
Program.counter = 1; | |
} | |
} | |
struct SG | |
{ | |
public void Test<T>(ref T t) where T : IA | |
{ | |
t.Method(); | |
} | |
} | |
class Program | |
{ | |
public static int counter; | |
static void Main(string[] args) | |
{ | |
S s; | |
var sw = new Stopwatch(); | |
sw.Start(); | |
for (int i = 0; i < 100000000; ++i) | |
{ | |
s = new S(); | |
new SG().Test(ref s); | |
} | |
sw.Stop(); | |
Console.WriteLine(sw.ElapsedMilliseconds); | |
Console.WriteLine(Program.counter); | |
return; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment