static void Main2() { SimpleStreamDemo demo = new SimpleStreamDemo(); //const int COUNT = 1000000; const bool RUN_LEGACY = true; //demo.PerfTestSimple(COUNT, RUN_LEGACY); //demo.PerfTestString(COUNT, RUN_LEGACY); //demo.PerfTestEmbedded(COUNT, RUN_LEGACY); //demo.PerfTestEnum(COUNT, true); //demo.PerfTestArray(COUNT, true); const int NWIND_COUNT = 1000; DAL.Database db = DAL.NWindTests.LoadDatabaseFromFile <DAL.Database>(RuntimeTypeModel.Default); Console.WriteLine("Sub-object format: {0}", DAL.Database.SubObjectFormat); SimpleStreamDemo.LoadTestItem(db, NWIND_COUNT, NWIND_COUNT, false, false, false, true, false, false, null); DatabaseCompat compat = DAL.NWindTests.LoadDatabaseFromFile <DatabaseCompat>(RuntimeTypeModel.Default); SimpleStreamDemo.LoadTestItem(compat, NWIND_COUNT, NWIND_COUNT, RUN_LEGACY, false, RUN_LEGACY, true, false, true, null); DatabaseCompatRem compatRem = DAL.NWindTests.LoadDatabaseFromFile <DatabaseCompatRem>(RuntimeTypeModel.Default); SimpleStreamDemo.LoadTestItem(compatRem, NWIND_COUNT, NWIND_COUNT, true, false, true, false, false, false, null); }
public void LargePayload() { DAL.Database db = DAL.NWindTests.LoadDatabaseFromFile <DAL.Database>(RuntimeTypeModel.Default); DatabaseCompat compat = Serializer.ChangeType <Database, DatabaseCompat>(db); DatabaseCompatRem rem = Serializer.ChangeType <Database, DatabaseCompatRem>(db); AppDomain app = AppDomain.CreateDomain("Isolated", null, AppDomain.CurrentDomain.BaseDirectory, AppDomain.CurrentDomain.RelativeSearchPath, false); try { DbServer server = (DbServer)app.CreateInstanceAndUnwrap( typeof(DbServer).Assembly.FullName, typeof(DbServer).FullName); const int LOOP = 5; Stopwatch dbTimer = Stopwatch.StartNew(); for (int i = 0; i < LOOP; i++) { compat = server.Roundtrip(compat); } dbTimer.Stop(); Stopwatch remTimer = Stopwatch.StartNew(); for (int i = 0; i < LOOP; i++) { rem = server.Roundtrip(rem); } remTimer.Stop(); // want to aim for twice the speed decimal factor = 0.50M; #if DEBUG factor = 1.2M; // be realistic in debug... #endif long target = (long)(dbTimer.ElapsedTicks * factor); Assert.LessOrEqual(3, 5, "args wrong way around!"); Assert.LessOrEqual(remTimer.ElapsedTicks, target); } finally { AppDomain.Unload(app); } }
public DatabaseCompatRem Roundtrip(DatabaseCompatRem db) { return(db); }