01: /*
02: * Copyright 2006-2007 The Scriptella Project Team.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package scriptella.expression;
17:
18: import scriptella.AbstractTestCase;
19: import scriptella.spi.MockParametersCallbacks;
20:
21: import java.util.Arrays;
22:
23: /**
24: * Tests {@link scriptella.expression.PropertiesSubstitutor} performance.
25: *
26: * @author Fyodor Kupolov
27: * @version 1.0
28: */
29: public class PropertiesSubstitutorPerfTest extends AbstractTestCase {
30: /**
31: * History:
32: * 13.05.2007 - Duron 1700 Mhz JDK6 - 2700 ms
33: * 09.03.2007 - Athlon 64 X2 2GHz - 1330 ms
34: * 08.03.2007 - Athlon 64 X2 2GHz - 1850 ms
35: * 05.09.2006 - Duron 1700 Mhz JDK5 - 4078 ms
36: */
37: public void test() {
38: PropertiesSubstitutor ps = new PropertiesSubstitutor(
39: MockParametersCallbacks.NAME);
40:
41: char[] fillC = new char[1000];
42: Arrays.fill(fillC, '-');
43: String fill = new String(fillC);
44:
45: String line = "Text ${subst1} $subst2 " + fill + ":$end //";
46: String exp = "Text subst1 subst2 " + fill + ":end //";
47:
48: for (int i = 0; i < 100000; i++) {
49: String s = ps.substitute(line);
50: assertEquals(exp, s);
51: }
52: }
53: }
|