static void Main(string[] args) { Console.WriteLine("Test starting"); GeneratorFacade gen = new GeneratorFacade(TimeMarkovConstructor()) ; TimeGenerateWords(gen, 10, 10000) ; TimeGenerateWords(gen, 10000, 10) ; TimeGenerateSentences(gen, 10000) ; TimeGenerateParagraphs(gen, 500, 10) ; TimeGenerateParagraphs(gen, 10, 500) ; Console.WriteLine("Test complete"); Console.ReadLine(); }
static void TimeGenerateWords(GeneratorFacade gen, int numIterations, int numWords) { Stopwatch timer = new Stopwatch() ; timer.Start() ; for(int i = 0 ; i < numIterations; i++) { gen.GenerateWords(numWords) ; } timer.Stop() ; double baseGenTime = timer.ElapsedMilliseconds/1000.0 ; Console.WriteLine(string.Format("Time to generate {0}x{1} words: {2:0.00} seconds", numIterations, numWords, baseGenTime)); }
static void TimeGenerateSentences(GeneratorFacade gen, int numSentences) { Stopwatch timer = new Stopwatch() ; timer.Start() ; for(int i = 0 ; i < numSentences ; i++) { gen.GenerateSentence(3) ; } timer.Stop() ; double baseGenTime = timer.ElapsedMilliseconds/1000.0 ; Console.WriteLine(string.Format("Time to generate {0} sentences: {1:0.00} seconds", numSentences, baseGenTime)); }
private void buttonBrowse_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog(); bool? result = dialog.ShowDialog(); if (result.HasValue) { if (result.Value) { try { _gen = new GeneratorFacade(new MarkovGenerator(File.ReadAllText(dialog.FileName))); buttonGenerate.IsEnabled = true; textStatus.Text = "Loaded " + dialog.FileName; } catch (Exception ex) { buttonGenerate.IsEnabled = false; MessageBox.Show("Error: " + ex.Message); } } } }