public static void RunCompositeCreationPerformanceTest(StructureServiceProvider ssp) { Int64 t0 = TestCreationPerformanceInLoop(LOOPS, () => new AnyObject(), "Minimum C# Object creation time", "object"); Int64 t1 = TestCreationPerformanceInLoop(LOOPS, () => ssp.NewPlainCompositeBuilder <AnyComposite>().Instantiate(), "Transient builder creation time", "composite"); //Int64 t2 = TestCreationPerformanceInLoop( LOOPS, () => ssp.NewValueBuilder<AnyValue>().Instantiate(), "Value builder creation time", "composite" ); Int64 t3 = TestCreationPerformanceInLoop(LOOPS, () => ssp.NewPlainCompositeBuilder <AnyObject>().Instantiate(), "Object builder creation time", "Qi4CS object"); Console.WriteLine("Transient builder: " + (t1 / t0) + "x"); //Console.WriteLine( "Value builder: " + ( t2 / t0 ) + "x" ); Console.WriteLine("Object builder: " + (t3 / t0) + "x"); }
public static void RunInvocationPerformanceTest(StructureServiceProvider ssp) { TestBase manualSimple = new TestMixin(); TestBase manualTypedConcernMixin = new TestMixin(); TestBase manualTypedConcernObj = new TestTypedConcern(manualTypedConcernMixin); TestBase manualGenericConcernMixin = new TestMixin(); TestBase manualGenericConcernObj = new ManualNextInvocator(manualGenericConcernMixin); Int64 t0 = TestInvocationPerformanceInLoop(LOOPS, manualSimple); Int64 t1 = TestInvocationPerformanceInLoop(LOOPS, manualTypedConcernObj); Int64 t2 = TestInvocationPerformanceInLoop(LOOPS, manualGenericConcernObj); Int64 t3 = TestInvocationPerformanceInLoop(LOOPS, ssp.NewPlainCompositeBuilder <TestComposite>().Instantiate()); Int64 t4 = TestInvocationPerformanceInLoop(LOOPS, ssp.NewPlainCompositeBuilder <TestWithTypedConcernComposite>().Instantiate()); Int64 t5 = TestInvocationPerformanceInLoop(LOOPS, ssp.NewPlainCompositeBuilder <TestWithGenericConcernComposite>().Instantiate()); Console.WriteLine("Simple: " + (t3 / t0) + "x"); Console.WriteLine("Typed concern: " + (t4 / t1) + "x"); Console.WriteLine("Generic concern: " + (t5 / t2) + "x"); }
public static void DummyMethod() { StructureServiceProvider ssp = null; Type myCompositeType = null; #region CompositeCreationCode1 // Acquiring CompositeBuilderInfo CompositeBuilderInfo <MyComposite> cbi = ssp.NewPlainCompositeBuilder <MyComposite>(); // Acquiring CompositeBuilder, type of composite not known at compile time CompositeBuilder cb = ssp.NewPlainCompositeBuilder(myCompositeType); // myCompositeType is of System.Type // Acquiring CompositeBuilder and using multiple types to filter out possible composites CompositeBuilder cbm = ssp.NewPlainCompositeBuilder(new[] { typeof(MyCompositePartialType1), typeof(MyCompositePartialType2) }); #endregion { #region CompositeCreationCode2 MyComposite composite = cbi.Instantiate(); #endregion } { #region CompositeCreationCode3 MyComposite composite = cb.Instantiate <MyComposite>(); MyComposite composite2 = (MyComposite)cb.InstantiateWithType(typeof(MyComposite)); // Both composite and composite2 will be same object. #endregion } { #region CompositeCreationCode4 MyCompositePartialType1 composite1 = cbm.Instantiate <MyCompositePartialType1>(); MyCompositePartialType2 composite2 = cbm.Instantiate <MyCompositePartialType2>(); // composite1 and composite2 may be different objects. #endregion } }