Author: schor Date: Fri Apr 19 18:57:29 2019 New Revision: 1857823 URL: http://svn.apache.org/viewvc?rev=1857823&view=rev Log: no Jira - allow repetitions for performance testing (manual)
Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/GrowingTheCasTestNoJcasCache.java Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/GrowingTheCasTestNoJcasCache.java URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/GrowingTheCasTestNoJcasCache.java?rev=1857823&r1=1857822&r2=1857823&view=diff ============================================================================== --- uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/GrowingTheCasTestNoJcasCache.java (original) +++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/GrowingTheCasTestNoJcasCache.java Fri Apr 19 18:57:29 2019 @@ -45,6 +45,8 @@ import junit.framework.TestCase; * */ public class GrowingTheCasTestNoJcasCache extends TestCase { + + private final static int REPETITIONS = 1; private AnalysisEngine ae = null; @@ -116,7 +118,7 @@ public class GrowingTheCasTestNoJcasCach e.printStackTrace(); assertTrue(false); } - StringBuffer buf = new StringBuffer(text.length() * 10); + StringBuilder buf = new StringBuilder(text.length() * 10); for (int i = 0; i < 10; i++) { buf.append(text); } @@ -131,35 +133,42 @@ public class GrowingTheCasTestNoJcasCach jcas.setDocumentText(text); int numberOfSentences = 0; int numberOfTokens = 0; - try { - // long time = System.currentTimeMillis(); - this.ae.process(jcas); - // time = System.currentTimeMillis() - time; - // System.out.println("Time for large CAS: " + new TimeSpan(time)); - numberOfSentences = jcas.getAnnotationIndex(Sentence.type).size(); - numberOfTokens = jcas.getAnnotationIndex(Token.type).size(); - // System.out.println(numberOfSentences); - // System.out.println(numberOfTokens); - } catch (AnalysisEngineProcessException e) { - e.printStackTrace(); - assertTrue(false); - } - this.smallHeapCas.setDocumentText(text); - try { - // long time = System.currentTimeMillis(); - this.ae.process(this.smallHeapCas); - // time = System.currentTimeMillis() - time; - // System.out.println("Time for small CAS: " + new TimeSpan(time)); - assertTrue(this.getClass().toString() + ": number of sentences does not match", - numberOfSentences == this.smallHeapCas.getAnnotationIndex(Sentence.type).size()); - assertTrue(this.getClass().toString() + ": number of tokens does not match", - numberOfTokens == this.smallHeapCas.getAnnotationIndex(Token.type).size()); - } catch (AnalysisEngineProcessException e) { - e.printStackTrace(); - assertTrue(false); - } finally { - smallHeapCas = null; // some junit runners hold onto instances of test classes after the test finishes + for (int i = 0; i < REPETITIONS; i++) { + jcas.reset(); + this.smallHeapCas.reset(); + jcas.setDocumentText(text); + numberOfSentences = 0; + numberOfTokens = 0; + try { + // long time = System.currentTimeMillis(); + this.ae.process(jcas); + // time = System.currentTimeMillis() - time; + // System.out.println("Time for large CAS: " + new TimeSpan(time)); + numberOfSentences = jcas.getAnnotationIndex(Sentence.type).size(); + numberOfTokens = jcas.getAnnotationIndex(Token.type).size(); + // System.out.println(numberOfSentences); + // System.out.println(numberOfTokens); + } catch (AnalysisEngineProcessException e) { + e.printStackTrace(); + assertTrue(false); + } + this.smallHeapCas.setDocumentText(text); + try { + // long time = System.currentTimeMillis(); + this.ae.process(this.smallHeapCas); + // time = System.currentTimeMillis() - time; + // System.out.println("Time for small CAS: " + new TimeSpan(time)); + assertTrue(this.getClass().toString() + ": number of sentences does not match", + numberOfSentences == this.smallHeapCas.getAnnotationIndex(Sentence.type).size()); + assertTrue(this.getClass().toString() + ": number of tokens does not match", + numberOfTokens == this.smallHeapCas.getAnnotationIndex(Token.type).size()); + } catch (AnalysisEngineProcessException e) { + e.printStackTrace(); + assertTrue(false); + } } + smallHeapCas = null; // some junit runners hold onto instances of test classes after the test finishes + } public static void main(String[] args) {