public void RunTests() { try { Console.WriteLine("Display mappings begin"); Console.WriteLine("Connection mappings:"); foreach (ConnectionMapping connectionMapping in Map.ConnectionMappings) { Console.WriteLine("ConnectionName:" + connectionMapping.ConnectionName); Console.WriteLine("ConnectionString:" + connectionMapping.ConnectionString); Console.WriteLine("DBParameterPrefix:" + connectionMapping.DBParameterPrefix); Console.WriteLine("DBVendor:" + connectionMapping.DBVendor); Console.WriteLine("ProviderInvariantName:" + connectionMapping.ProviderInvariantName); Console.WriteLine("UsedDBParameterPrefix:" + connectionMapping.UsedDBParameterPrefix); Console.WriteLine("-------------------------------------------------------------------"); } Console.WriteLine("Entity mappings:"); foreach (EntityMapping entityMapping in Map.EntityMappings) { Console.WriteLine("EntityType:" + entityMapping.EntityType); Console.WriteLine("ConnectionName:" + entityMapping.ConnectionName); Console.WriteLine("TableName:" + entityMapping.TableName); Console.WriteLine("SchemaName:" + entityMapping.SchemaName); if (entityMapping.PrimaryKeyColumnNames != null) { Console.WriteLine("PrimaryKeyColumnNames:"); foreach (string primaryKeyColumnName in entityMapping.PrimaryKeyColumnNames) { Console.WriteLine("PrimaryKeyColumnName:" + primaryKeyColumnName); } } if (entityMapping.TimestampMapping != null) { Console.WriteLine("TimestampMapping:"); Console.WriteLine("ColumnName:" + entityMapping.TimestampMapping.ColumnName); Console.WriteLine("NestedPropertyName:" + entityMapping.TimestampMapping.NestedPropertyName); Console.WriteLine("ValueProviderSet:"); Console.WriteLine("SchemaName:" + entityMapping.TimestampMapping.ValueProviderSet.SchemaName); Console.WriteLine("DBFunctionName:" + entityMapping.TimestampMapping.ValueProviderSet.DBFunctionName); Console.WriteLine("SequenceName:" + entityMapping.TimestampMapping.ValueProviderSet.SequenceName); Console.WriteLine("FunctionDelegate:" + entityMapping.TimestampMapping.ValueProviderSet.FunctionDelegate); Console.WriteLine("ValueProvider:" + entityMapping.TimestampMapping.ValueProviderSet.ValueProvider); } Console.WriteLine("TriggerActions:"); foreach (When when in entityMapping.TriggerActions) { Console.WriteLine("When:" + when); } Console.WriteLine("insertTestAutoSetColumnMappings:"); foreach (AutoSetColumnMapping autoSetColumnMapping in entityMapping.InsertAutoSetColumnMappings) { Console.WriteLine("ColumnName:" + autoSetColumnMapping.ColumnName); Console.WriteLine("ValueProviderSet:"); Console.WriteLine("SchemaName:" + autoSetColumnMapping.ValueProviderSet.SchemaName); Console.WriteLine("DBFunctionName:" + autoSetColumnMapping.ValueProviderSet.DBFunctionName); Console.WriteLine("SequenceName:" + autoSetColumnMapping.ValueProviderSet.SequenceName); Console.WriteLine("FunctionDelegate:" + autoSetColumnMapping.ValueProviderSet.FunctionDelegate); Console.WriteLine("ValueProvider:" + autoSetColumnMapping.ValueProviderSet.ValueProvider); } Console.WriteLine("updateTestAutoSetColumnMappings:"); foreach (AutoSetColumnMapping autoSetColumnMapping in entityMapping.UpdateAutoSetColumnMappings) { Console.WriteLine("ColumnName:" + autoSetColumnMapping.ColumnName); Console.WriteLine("ValueProviderSet:"); Console.WriteLine("SchemaName:" + autoSetColumnMapping.ValueProviderSet.SchemaName); Console.WriteLine("DBFunctionName:" + autoSetColumnMapping.ValueProviderSet.DBFunctionName); Console.WriteLine("SequenceName:" + autoSetColumnMapping.ValueProviderSet.SequenceName); Console.WriteLine("FunctionDelegate:" + autoSetColumnMapping.ValueProviderSet.FunctionDelegate); Console.WriteLine("ValueProvider:" + autoSetColumnMapping.ValueProviderSet.ValueProvider); } Console.WriteLine("LogicaldeleteTestAutoSetColumnMappings:"); foreach (AutoSetColumnMapping autoSetColumnMapping in entityMapping.LogicalDeleteAutoSetColumnMappings) { Console.WriteLine("ColumnName:" + autoSetColumnMapping.ColumnName); Console.WriteLine("ValueProviderSet:"); Console.WriteLine("SchemaName:" + autoSetColumnMapping.ValueProviderSet.SchemaName); Console.WriteLine("DBFunctionName:" + autoSetColumnMapping.ValueProviderSet.DBFunctionName); Console.WriteLine("SequenceName:" + autoSetColumnMapping.ValueProviderSet.SequenceName); Console.WriteLine("FunctionDelegate:" + autoSetColumnMapping.ValueProviderSet.FunctionDelegate); Console.WriteLine("ValueProvider:" + autoSetColumnMapping.ValueProviderSet.ValueProvider); } Console.WriteLine("ColumnMappings:"); foreach (ColumnMapping columnMapping in entityMapping.ColumnMappings) { Console.WriteLine("ColumnName:" + columnMapping.ColumnName); Console.WriteLine("NestedPropertyName:" + columnMapping.NestedPropertyName); Console.WriteLine("IsDBNullableValueType:" + columnMapping.IsDBNullableValueType); } Console.WriteLine("QueryMappings:"); foreach (QueryMapping queryMapping in entityMapping.QueryMappings) { Console.WriteLine("QueryName:" + queryMapping.QueryName); Console.WriteLine("selectTestSql:" + queryMapping.SelectSql); Console.WriteLine("IsQueryResultCached:" + queryMapping.IsQueryResultCached); Console.WriteLine("MaxNumberOfQueriesToHoldInCache:" + queryMapping.MaxNumberOfQueriesToHoldInCache); } Console.WriteLine("-------------------------------------------------------------------"); } Console.WriteLine("Display mappings complete"); Console.WriteLine("Press a key to continue"); Console.ReadKey(); Console.WriteLine("Singlethread test 1 begin"); benchmark(1, "allBenchmarks", delegate { allBenchmarks(); }); Console.WriteLine("Singlethread test 1 complete"); Console.WriteLine("Press a key to continue"); Console.ReadKey(); Console.WriteLine("Change mappings test begin"); EntityMapping entityMappingToChange = Map.EntityMappings[0]; entityMappingToChange.ChangeConnectionName("SqlServerTest"); entityMappingToChange.ChangeSchemaName("DBO"); entityMappingToChange.ChangeTableName("TEST2"); entityMappingToChange.PrimaryKeyMapping.ChangeSchemaName("DBO"); entityMappingToChange.TimestampMapping.ChangeSchemaName("DBO"); foreach (AutoSetColumnMapping autoSetColumnMapping in entityMappingToChange.InsertAutoSetColumnMappings) { autoSetColumnMapping.ChangeSchemaName("DBO"); } foreach (AutoSetColumnMapping autoSetColumnMapping in entityMappingToChange.UpdateAutoSetColumnMappings) { autoSetColumnMapping.ChangeSchemaName("DBO"); } foreach (AutoSetColumnMapping autoSetColumnMapping in entityMappingToChange.LogicalDeleteAutoSetColumnMappings) { autoSetColumnMapping.ChangeSchemaName("DBO"); } CommonDefinitions.Connection = (MyConnection)Enum.Parse(typeof(MyConnection), "SqlServerTest"); CommonDefinitions.Schema = (MySchema)Enum.Parse(typeof(MySchema), "DBO"); entityMappingToChange.GenerateCommands(); benchmark(1, "allBenchmarks", delegate { allBenchmarks(); }); Console.WriteLine("Change mappings test complete"); Console.WriteLine("Press a key to continue"); Console.ReadKey(); Console.WriteLine("Singlethread test 2 begin"); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); int k; for (k = 0; k < 1000; k++) { callFunctionProcedureTest(); selectTest(); insertTest(); updateTest(); deleteTest(); } stopwatch.Stop(); Console.WriteLine("Count:" + k * 5 + " Timespan(ms):" + stopwatch.ElapsedMilliseconds + " avg ms: " + stopwatch.ElapsedMilliseconds / k / 5); Console.WriteLine("Singlethread test 2 complete"); Console.WriteLine("Press a key to continue"); Console.ReadKey(); Console.WriteLine("Multithread test 1 begin"); stopwatch = new Stopwatch(); stopwatch.Start(); for (k = 0; k < 1000; k++) { Thread thread = new Thread(callFunctionProcedureTest); thread.Start(); thread = new Thread(selectTest); thread.Start(); thread = new Thread(insertTest); thread.Start(); thread = new Thread(updateTest); thread.Start(); thread = new Thread(deleteTest); thread.Start(); //Thread.Sleep(lag); //thread.Join(); } stopwatch.Stop(); Console.WriteLine("Count:" + k * 5 + " Timespan(ms):" + stopwatch.ElapsedMilliseconds + " avg ms: " + stopwatch.ElapsedMilliseconds / k / 5); Console.WriteLine("Multithread test 1 complete"); Console.WriteLine("Press a key to continue"); Console.ReadKey(); Console.WriteLine("Multithread test 2 begin"); Console.WriteLine("callFunctionProcedureTest"); stopwatch = new Stopwatch(); stopwatch.Start(); for (k = 0; k < 1000; k++) { Thread thread = new Thread(callFunctionProcedureTest); thread.Start(); //Thread.Sleep(20); } stopwatch.Stop(); Console.WriteLine("Count:" + k + " Timespan(ms):" + stopwatch.ElapsedMilliseconds + " avg ms: " + stopwatch.ElapsedMilliseconds / k); Console.WriteLine("selectTest"); stopwatch = new Stopwatch(); stopwatch.Start(); for (k = 0; k < 1000; k++) { Thread thread = new Thread(selectTest); thread.Start(); //Thread.Sleep(20); } stopwatch.Stop(); Console.WriteLine("Count:" + k + " Timespan(ms):" + stopwatch.ElapsedMilliseconds + " avg ms: " + stopwatch.ElapsedMilliseconds / k); Console.WriteLine("insertTest"); stopwatch = new Stopwatch(); stopwatch.Start(); for (k = 0; k < 1000; k++) { Thread thread = new Thread(insertTest); thread.Start(); //Thread.Sleep(20); } stopwatch.Stop(); Console.WriteLine("Count:" + k + " Timespan(ms):" + stopwatch.ElapsedMilliseconds + " avg ms: " + stopwatch.ElapsedMilliseconds / k); Console.WriteLine("updateTest"); stopwatch = new Stopwatch(); stopwatch.Start(); for (k = 0; k < 1000; k++) { Thread thread = new Thread(updateTest); thread.Start(); //Thread.Sleep(20); } stopwatch.Stop(); Console.WriteLine("Count:" + k + " Timespan(ms):" + stopwatch.ElapsedMilliseconds + " avg ms: " + stopwatch.ElapsedMilliseconds / k); Console.WriteLine("deleteTest"); stopwatch = new Stopwatch(); stopwatch.Start(); for (k = 0; k < 1000; k++) { Thread thread = new Thread(deleteTest); thread.Start(); //Thread.Sleep(20); } stopwatch.Stop(); Console.WriteLine("Count:" + k + " Timespan(ms):" + stopwatch.ElapsedMilliseconds + " avg ms: " + stopwatch.ElapsedMilliseconds / k); Console.WriteLine("Multithread test 2 complete"); Console.WriteLine("Press a key to exit"); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.WriteLine("--------------------------------------------------------------------"); Console.WriteLine(ex.InnerException.Message); Console.WriteLine(ex.InnerException.StackTrace); } }