Skip to content

Instantly share code, notes, and snippets.

@jkotas
Created January 23, 2018 15:07
Show Gist options
  • Save jkotas/2c6d95a208accb77b50fbc0e4fdd28f1 to your computer and use it in GitHub Desktop.
Save jkotas/2c6d95a208accb77b50fbc0e4fdd28f1 to your computer and use it in GitHub Desktop.
Interop overhead microbenchmark
using System;
using System.Security;
using System.Runtime.InteropServices;
class Test
{
[DllImport("kernel32.dll")]
[SuppressUnmanagedCodeSecurityAttribute]
extern static int GetTickCount();
static void Main() {
int start = Environment.TickCount;
for (int i = 0; i < 1000000000; i++)
GetTickCount();
int end = Environment.TickCount;
Console.WriteLine(end-start);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment