public void PerfTestDb() { byte[] blob = File.ReadAllBytes(NWindTests.GetNWindBinPath()); using (MemoryStream ms = new MemoryStream(blob)) { var model = TypeModel.Create(); Type type = typeof(Database); model.Deserialize(ms, null, type); var compiled = model.Compile(); /*erializer.PrepareSerializer<Database>(); * Serializer.Deserialize<Database>(ms);*/ Stopwatch watch = Stopwatch.StartNew(); for (int i = 0; i < 1000; i++) { ms.Position = 0; //Serializer.Deserialize<Database>(ms); compiled.Deserialize(ms, null, type); } watch.Stop(); Console.WriteLine(watch.ElapsedMilliseconds); if (Debugger.IsAttached) { Console.WriteLine("(press any key)"); Console.ReadKey(); } } }
public static T LoadDatabaseFromFile <T>(TypeModel model) where T : class, new() { // otherwise... using (Stream fs = File.OpenRead(NWindTests.GetNWindBinPath())) { return((T)model.Deserialize(fs, null, typeof(T))); } }
public static T LoadDatabaseFromFile <T>(TypeModel model) where T : class, new() { // otherwise... using Stream fs = File.OpenRead(NWindTests.GetNWindBinPath()); #pragma warning disable CS0618 return((T)model.Deserialize(fs, null, typeof(T))); #pragma warning restore CS0618 }