Skip to content

Instantly share code, notes, and snippets.

@juanplopes
Created January 11, 2011 15:49
Show Gist options
  • Save juanplopes/774592 to your computer and use it in GitHub Desktop.
Save juanplopes/774592 to your computer and use it in GitHub Desktop.
var foo = new Foo();
var bar = typeof(Foo).GetMethod("Bar");
var s = Stopwatch.StartNew();
for (int i = 0; i < 5000000; i++)
foo.Bar(i);
Console.WriteLine("Sem reflection: {0}", s.Elapsed);
s.Restart();
for (int i = 0; i < 5000000; i++)
bar.Invoke(foo, new object[] { i });
Console.WriteLine("Com reflection: {0}", s.Elapsed);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment