Skip to content

Instantly share code, notes, and snippets.

@marek-safar
Created March 12, 2012 15:22
Show Gist options
  • Save marek-safar/2022611 to your computer and use it in GitHub Desktop.
Save marek-safar/2022611 to your computer and use it in GitHub Desktop.
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