public static void RunWithOptions(Options options) { var container = new StandardKernel(); container.Bind<Options>().ToConstant(options); if (options.WordList != null) container.Bind<IWordSource>().To<WordListReader>(); else if (options.TextDocument != null) { container.Bind<ITextSource>().To<TextDocumentReader>(); container.Bind<IWordSource>().To<TextSplitter>(); } else throw new ArgumentException("You should specify either --word-list or --text"); container.Bind<IGrammarInfoParser>().To<MystemGrammarInfoParser>(); container.Bind<IWordFilter>().To<PartOfSpeechFilter>(); container.Bind<IWordFilter>().To<LengthFilter>(); container.Bind<FontFamily>().ToConstant(FontLoader.LoadFontFamily(options.FontFile)); container.Bind<IFontManager>().To<LinearSizeFontManager>(); container.Bind<ICloudGenerator>().To<GravityCloudGenerator>(); container.Bind<IColorManager>().To<RandomColorManager>(); container.Bind<ICloudRenderer>().To<BitmapRenderer>(); container.Get<CloudProcessor>().Process(); }
public void processCloud_onWordsFromWarAndPeace() { var options = new Options { BgColor = Color.White, //TextColor = Color.Black, Count = 100, FontFile = "Monospace", Width = 400, Height = 400, MinLength = 3, OutputImage = "output.png", TextDocument = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Examples", "WarAndPeace_Part1.txt") }; for (var i = 0; i < WarmupRunsCount; i++) Program.RunWithOptions(options); var watch = Stopwatch.StartNew(); for (int i = 0; i < MeasuredRunsCount; i++) Program.RunWithOptions(options); var averageTimeMsecs = (int)Math.Round(watch.Elapsed.TotalMilliseconds / MeasuredRunsCount); Console.WriteLine($"Average time: {averageTimeMsecs} ms"); }