@@ -0,0 +1,2526 @@
+/* LanguageTool, a natural language style checker%0A * Copyright (C) 2013 Daniel Naber (http://www.danielnaber.de)%0A *%0A * This library is free software; you can redistribute it and/or%0A * modify it under the terms of the GNU Lesser General Public%0A * License as published by the Free Software Foundation; either%0A * version 2.1 of the License, or (at your option) any later version.%0A *%0A * This library is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU%0A * Lesser General Public License for more details.%0A *%0A * You should have received a copy of the GNU Lesser General Public%0A * License along with this library; if not, write to the Free Software%0A * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301%0A * USA%0A */%0Apackage org.languagetool.rules.patterns;%0A%0Aimport org.languagetool.JLanguageTool;%0Aimport org.languagetool.Language;%0Aimport org.languagetool.tools.StringTools;%0A%0Aimport java.io.FileInputStream;%0Aimport java.io.IOException;%0A%0A/**%0A * Check performance per sentence. Not a unit test, for interactive use only.%0A */%0Afinal class PerformanceTest %7B%0A%0A  public static void main(String%5B%5D args) throws IOException %7B%0A    if (args.length != 2) %7B%0A      System.out.println(%22Usage: %22 + RuleNumberScalabilityTest.class.getSimpleName() + %22 %3ClanguageCode%3E %3Ctext_file%3E%22);%0A      System.exit(1);%0A    %7D%0A    JLanguageTool langTool = new JLanguageTool(Language.getLanguageForShortName(args%5B0%5D));%0A    String text = StringTools.readStream(new FileInputStream(args%5B1%5D), %22utf-8%22);%0A    int sentenceCount = langTool.sentenceTokenize(text).size();%0A    langTool.activateDefaultPatternRules();%0A    System.out.println(%22Text length: %22 + text.length() + %22 chars, %22 + sentenceCount + %22 sentences%22);%0A%0A    System.out.println(%22Warmup...%22);%0A    long startTime1 = System.currentTimeMillis();%0A    langTool.check(text);%0A    long runTime1 = System.currentTimeMillis() - startTime1;%0A    float timePerSentence1 = (float)runTime1 / sentenceCount;%0A    System.out.printf(%22Check time on first run: %22 + runTime1 + %22ms = %25.1fms per sentence%5Cn%22, timePerSentence1);%0A%0A    System.out.println(%22Checking text...%22);%0A    long startTime2 = System.currentTimeMillis();%0A    langTool.check(text);%0A    long runTime2 = System.currentTimeMillis() - startTime2;%0A    float timePerSentence2 = (float)runTime2 / sentenceCount;%0A    System.out.printf(%22Check time after warmup: %22 + runTime2 + %22ms = %25.1fms per sentence%5Cn%22, timePerSentence2);%0A  %7D%0A%0A%7D%0A

add a small test method that prints the performance per sentence (not a unit test)