private void buttonGenerate_Click(object sender, RoutedEventArgs e) { string resultString = string.Empty; try { if (radioSentence.IsChecked.Value) { resultString = _gen.GenerateSentence(Convert.ToInt32(textSentence_MinWords.Text)); } else if (radioWords.IsChecked.Value) { resultString = _gen.GenerateWords(Convert.ToInt32(textWords_NumWords.Text)); } else if (radioTitle.IsChecked.Value) { resultString = _gen.GenerateTitle(Convert.ToInt32(textTitle_NumWords.Text)); } else if (radioParagraphs.IsChecked.Value) { resultString = _gen.GenerateParagraphs(Convert.ToInt32(textParagraphs_NumParagraphs.Text)); } else { throw new NotImplementedException(); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } textOutput.Text = resultString; }
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)); }