Пример #1
0
        private long[] TestLoop(ModuleConfig config, JsonSerializerSettings jsonSettings)
        {
            var stopWatch = new Stopwatch();
            var ids       = new List <long>();

            // Write time
            using (var uow = TestFactory.Create(ContextMode.ChangeTracking))
            {
                stopWatch.Start();
                for (var i = 0; i < LoopCount; i++)
                {
                    ids.Add(WriteLoop(uow, config, jsonSettings));
                }
                stopWatch.Stop();
            }
            var writeTime = stopWatch.ElapsedMilliseconds;

            // Read time
            using (var uow = TestFactory.Create(ContextMode.AllOff))
            {
                stopWatch.Restart();
                foreach (var id in ids)
                {
                    var result = ReadLoop(uow, id, jsonSettings);
                }
                stopWatch.Stop();
            }
            var readTime = stopWatch.ElapsedMilliseconds;

            return(new[] { writeTime, readTime });
        }
Пример #2
0
        private long WriteLoop(IUnitOfWork uow, ModuleConfig config, JsonSerializerSettings settings)
        {
            var json   = JsonConvert.SerializeObject(config, typeof(IConfig), settings);
            var entity = uow.GetRepository <IJsonEntityRepository>().Create(json);

            uow.SaveChanges();
            return(entity.Id);
        }
Пример #3
0
        private void JitRun(ModuleConfig config)
        {
            var jsonSettings = new JsonSerializerSettings {
                TypeNameHandling = TypeNameHandling.All
            };

            TestLoop(config, jsonSettings);
        }
Пример #4
0
        private ModuleConfig CreateConfig()
        {
            var config = new ModuleConfig
            {
                BoolValue    = true,
                ConfigState  = ConfigState.Valid,
                DoubleValue  = 126.251,
                EnumValue    = ConfigEnumeration.Value2,
                IntegerValue = 12035,
                SleepTime    = 100,
                LogLevel     = LogLevel.Info,
                LongValue    = 1281259787,
                StringValue  = "hasojgwbngäqwbvqwvb",
                TestPlugin   = new TestPluginConfig1
                {
                    PluginBoolValue    = true,
                    PluginDoubleValue  = 10.5,
                    PluginStringValue  = "owgegvuqwvqwe",
                    PluginEnumValue    = ConfigEnumeration.Value2,
                    PluginIntegerValue = 7505,
                    PluginLongValue    = 18364752513
                },
                Plugins = new List <TestPluginConfig>
                {
                    new TestPluginConfig2
                    {
                        PluginBoolValue    = true,
                        PluginDoubleValue  = 10.5,
                        PluginStringValue  = "owgegvuqwvqwe",
                        PluginEnumValue    = ConfigEnumeration.Value2,
                        PluginIntegerValue = 7505,
                        PluginLongValue    = 18364752513
                    },
                    new TestPluginConfig1
                    {
                        PluginBoolValue    = true,
                        PluginDoubleValue  = 10.5,
                        PluginStringValue  = "owgegvuqwvqwe",
                        PluginEnumValue    = ConfigEnumeration.Value2,
                        PluginIntegerValue = 7505,
                        PluginLongValue    = 18364752513
                    },
                }
            };

            return(config);
        }
 public ModuleConfig EchoModuleConfig(ModuleConfig moduleConfig)
 {
     return(moduleConfig);
 }