Skip to content

Instantly share code, notes, and snippets.

@spetroll
Created December 27, 2012 15:44
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 spetroll/4389176 to your computer and use it in GitHub Desktop.
Save spetroll/4389176 to your computer and use it in GitHub Desktop.
public static readonly int[] HR = new int[32487834];
private static unsafe void Init()
{
var lutFileInfo = new FileInfo(@"C:\Handranks.dat");
if (!lutFileInfo.Exists)
{
GenerateFile();
}
Console.Write("Loading HandRanks..");
var timer = Stopwatch.StartNew();
using (var lutFile = new FileStream(@"C:\Handranks.dat", FileMode.Open, FileAccess.Read, FileShare.ReadWrite,4096))
{
var tempBuffer = new byte[32487834*4];
lutFile.Read(tempBuffer, 0, 32487834*4);
fixed (int* pLut = HR)
{
Marshal.Copy(tempBuffer, 0, (IntPtr) pLut, 32487834*4);
}
tempBuffer = null;
}
timer.Stop();
Console.WriteLine(" done");
Console.WriteLine("\t Time Required: {0}ms", timer.ElapsedMilliseconds);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment