Skip to content

Instantly share code, notes, and snippets.

@kkozmic
Created June 26, 2014 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkozmic/8362bc57f24d7adf68e2 to your computer and use it in GitHub Desktop.
Save kkozmic/8362bc57f24d7adf68e2 to your computer and use it in GitHub Desktop.
AttributesToAvoidReplicating.Add<MarshalAsAttribute>();
var pg = new ProxyGenerator();
var tasks = new List<Task>();
var interfaces =
typeof (object).Assembly.GetExportedTypes()
.Where(t => t.IsInterface && t.IsGenericTypeDefinition == false)
.OrderBy(t => t.Name).Take(10);
for (int _ = 0; _ < 100; _++)
{
foreach (var @interface in interfaces)
{
var i = @interface;
tasks.Add(new Task(() => pg.CreateInterfaceProxyWithoutTarget(i)));
}
}
var allTasks = tasks.ToArray();
var sw = Stopwatch.StartNew();
Array.ForEach(allTasks, t => t.Start());
Task.WaitAll(allTasks);
Console.WriteLine();
Console.WriteLine("All done in " + sw.ElapsedMilliseconds + "ms");
Console.ReadKey();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment