public void LoggingPerformance() { var log = LogManager.GetLogger(typeof(ThePerformance)); var averageDuration = TimeMeasureHelper.MeasureAction(10000, "Log.Write", () => log.WriteWithData("this is a test", null, LogEvent.Error)); Assert.IsTrue(averageDuration < 1d); }
public void WarmsUpAllTypes() { var serializer = SerializationFactory.GetBinarySerializer(); TimeMeasureHelper.MeasureAction(5, "Binary serializer warmup", () => serializer.Warmup(), () => { TypeCache.InitializeTypes(); ConsoleHelper.Write("TypeCache contains {0} items", TypeCache.GetTypes().Count()); ConsoleHelper.Write("TypeCache contains {0} ModelBase items", TypeCache.GetTypes(x => typeof(ModelBase).IsAssignableFromEx(x)).Count()); }); // TODO: No way to see if this is cached (otherwise we have to write this feature on DataContractSerializerFactory) // This unit test is written to easily test this functionality though. }
public void WarmsUpAllTypes() { TestSerializationOnAllSerializers((serializer, config, description) => { TimeMeasureHelper.MeasureAction(5, string.Format("{0} serializer warmup", serializer.GetType().Name), () => serializer.Warmup(), () => { TypeCache.InitializeTypes(); ConsoleHelper.Write("TypeCache contains {0} items", TypeCache.GetTypes().Count()); ConsoleHelper.Write("TypeCache contains {0} ModelBase items", TypeCache.GetTypes(x => x.IsModelBase()).Count()); }); }); // TODO: No way to see if this is cached (otherwise we have to write this feature on DataContractSerializerFactory) // This unit test is written to easily test this functionality though. }
public void WarmsUpSpecificTypes() { var typesToWarmup = new Type[] { typeof(CircularTestModel), typeof(TestModel) }; var serializer = SerializationFactory.GetXmlSerializer(); TimeMeasureHelper.MeasureAction(5, "Xml serializer warmup", () => serializer.Warmup(typesToWarmup), () => { TypeCache.InitializeTypes(false); ConsoleHelper.Write("TypeCache contains {0} items", TypeCache.GetTypes().Count()); ConsoleHelper.Write("TypeCache contains {0} ModelBase items", TypeCache.GetTypes(x => typeof(ModelBase).IsAssignableFromEx(x)).Count()); }); // TODO: No way to see if this is cached (otherwise we have to write this feature on DataContractSerializerFactory) // This unit test is written to easily test this functionality though. }
public void WarmsUpSpecificTypes() { var typesToWarmup = new[] { typeof(CircularTestModel), typeof(TestModel) }; TestSerializationOnAllSerializers((serializer, description) => { TimeMeasureHelper.MeasureAction(5, string.Format("{0} serializer warmup", serializer.GetType().Name), () => serializer.Warmup(typesToWarmup), () => { TypeCache.InitializeTypes(); ConsoleHelper.Write("TypeCache contains {0} items", TypeCache.GetTypes().Count()); ConsoleHelper.Write("TypeCache contains {0} ModelBase items", TypeCache.GetTypes(x => typeof(ModelBase).IsAssignableFromEx(x)).Count()); }); }); // TODO: No way to see if this is cached (otherwise we have to write this feature on DataContractSerializerFactory) // This unit test is written to easily test this functionality though. }
private void PerformanceTest(int typesPerThread) { TimeMeasureHelper.MeasureAction(5, "Multithreaded initialization", () => new RedirectDeserializationBinder(typesPerThread), () => TypeCache.InitializeTypes()); }