@@ -165,22 +165,10 @@ public void testSetRuleTypeToRulesIllegalArgumentException() {
165165 }
166166
167167 /**
168- * Runs between 1.1 and 13 seconds at length 40 for me (Gary Gregory, 2011/08/06)
168+ * (Un)luckily, the worse performing test because of the data in {@link TEST_CHARS}
169169 *
170170 * @throws EncoderException
171171 */
172- @ Test (/* timeout = 20000L */ )
173- public void testSpeedCheckRandom () throws EncoderException {
174- BeiderMorseEncoder bmpm = this .createGenericApproxEncoder ();
175- StringBuffer stringBuffer = new StringBuffer ();
176- Random rand = new Random ();
177- stringBuffer .append (TEST_CHARS [rand .nextInt (TEST_CHARS .length )]);
178- for (int i = 0 ; i < 40 ; i ++) {
179- bmpm .encode (stringBuffer .toString ());
180- stringBuffer .append (TEST_CHARS [rand .nextInt (TEST_CHARS .length )]);
181- }
182- }
183-
184172 @ Test (/* timeout = 20000L */ )
185173 public void testSpeedCheck () throws EncoderException {
186174 BeiderMorseEncoder bmpm = this .createGenericApproxEncoder ();
@@ -194,4 +182,35 @@ public void testSpeedCheck() throws EncoderException {
194182 stringBuffer .append (TEST_CHARS [j ]);
195183 }
196184 }
185+
186+ /**
187+ * Another odd performance edge case.
188+ *
189+ * @throws EncoderException
190+ */
191+ @ Test (/* timeout = 20000L */ )
192+ public void testSpeedCheckAZ () throws EncoderException {
193+ BeiderMorseEncoder bmpm = this .createGenericApproxEncoder ();
194+ String phrase = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz" ;
195+ for (int i = 1 ; i <= phrase .length (); i ++) {
196+ bmpm .encode (phrase .subSequence (0 , i ));
197+ }
198+ }
199+
200+ /**
201+ * Runs between 1.6 and 13 seconds at length 40 for me (Gary Gregory, 2011/08/06)
202+ *
203+ * @throws EncoderException
204+ */
205+ @ Test (/* timeout = 20000L */ )
206+ public void testSpeedCheckRandom () throws EncoderException {
207+ BeiderMorseEncoder bmpm = this .createGenericApproxEncoder ();
208+ StringBuffer stringBuffer = new StringBuffer ();
209+ Random rand = new Random ();
210+ stringBuffer .append (TEST_CHARS [rand .nextInt (TEST_CHARS .length )]);
211+ for (int i = 0 ; i < 40 ; i ++) {
212+ bmpm .encode (stringBuffer .toString ());
213+ stringBuffer .append (TEST_CHARS [rand .nextInt (TEST_CHARS .length )]);
214+ }
215+ }
197216}
0 commit comments