public void Test_DataLoaderFactory_GetLoader() { // 从代理程序集中获取的类型 object loader1 = DataLoaderFactory.GetLoader <Customer>(); Assert.IsNotNull(loader1); Console.WriteLine(loader1.GetType().Name); // 没有注册的类型 object loader2 = DataLoaderFactory.GetLoader <NameValue>(); Assert.IsNotNull(loader2); Assert.IsTrue(loader2.GetType() == typeof(DefaultDataLoader <NameValue>)); }
public void Test_DataLoaderFactory_RegisterType() { // 没有注册的类型 object loader = DataLoaderFactory.GetLoader <NameValue>(); // 注册加载器类型 DataLoaderFactory.RegisterType(loader.GetType()); // 尝试获取 object loader2 = DataLoaderFactory.GetLoader <NameValue>(); Assert.IsNotNull(loader2); Assert.IsTrue(loader2.GetType() == typeof(DefaultDataLoader <NameValue>)); // 移除注册 RemoveRegister(typeof(NameValue)); }
public static void Main(string[] args) { // note: we assume input args are valid full paths and does not include error handling here. if (args.Length < 1) { Console.WriteLine("Please specfiy an input path and retry..."); Console.ReadLine(); return; } // Data input var inputPath = Path.GetFullPath(args[0]); var loader = DataLoaderFactory.GetLoader(inputPath); var allData = loader.Load(inputPath); Statistics.Instance.LoadedCount = allData.Count; // Process data set // - Here simply define a single validator that takes away data points who have significantly changed // over the previous date's data. // - To add other criteria against 'outlier', implement such referenced-criteria on enriched data // and validate against that criteria. var proc = new EnrichDataProcessor(new[] { new IntradayPriceReturn5PercentValidator() }); var result = proc.Process(allData); Statistics.Instance.ValidatedCount = result.Count; // Data output var outputPath = args.Length == 2 ? Path.GetFullPath(args[1]) : inputPath; var dumper = DataDumperFactory.GetDumper(outputPath); dumper.Write(result, outputPath); // Print statistics Console.WriteLine("[{0}] Completed. Details:\n", DateTime.Now); Console.WriteLine(Statistics.Instance.ToString()); Console.WriteLine("Press any key to close..."); Console.ReadLine(); }
public void Test_DataLoaderFactory_RegisterInstance() { // 没有注册的类型 object loader = DataLoaderFactory.GetLoader <NameValue>(); // 注册加载器实例 DataLoaderFactory.RegisterInstance(loader); // 尝试获取 object loader2 = DataLoaderFactory.GetLoader <NameValue>(); Assert.IsTrue(object.ReferenceEquals(loader, loader2)); // 移除注册 RemoveRegister(typeof(NameValue)); // 确认移除 object loader3 = DataLoaderFactory.GetLoader <NameValue>(); Assert.IsFalse(object.ReferenceEquals(loader, loader3)); }
static void Main(string[] args) { if (args.Length != 2) { PrintHelp(); return; } var data1 = DataLoaderFactory.GetLoader(args[0]).LoadBenchmarks(args[0]); var data2 = DataLoaderFactory.GetLoader(args[1]).LoadBenchmarks(args[1]); var tableFormat = new TableFormatting(); var comparers = new List <BaseValueComparer> { new MeanComparer(), new AllocatedComparer(), new Gen0Comparer(), new Gen1Comparer(), new Gen2Comparer(), new CompletedWorkItemsComparer(), new LockContentionsComparer(), new BranchInstructionsComparer(), new BranchMispredictionsComparer(), new CacheMissesComparer(), new NativeAllocatedComparer(), new NativeLeakComparer() }; foreach (var comparer in comparers) { var comparedData = comparer.Compare(data1, data2); if (comparedData.Length > 0) { ConsoleTable.From(comparedData).Write(tableFormat); Console.WriteLine(); } } }