Exemplo n.º 1
0
        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();
                }
            }
        }
Exemplo n.º 2
0
 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)));
     }
 }
Exemplo n.º 3
0
        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
        }