KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > svggen > DoubleStringPerformanceTest


1 /*
2
3    Copyright 2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.svggen;
19
20 import org.w3c.dom.Document JavaDoc;
21 import org.w3c.dom.DOMImplementation JavaDoc;
22
23 import org.apache.batik.dom.svg.SVGDOMImplementation;
24 import org.apache.batik.test.PerformanceTest;
25
26 /**
27  * This test checks that there is no performance degradation in the
28  * doubleString utility method.
29  *
30  * @author <a HREF="mailto:vincent.hardy@sun.com">Vincent Hardy</a>
31  * @version $Id: DoubleStringPerformanceTest.java,v 1.4 2004/08/18 07:16:44 vhardy Exp $
32  */

33 public class DoubleStringPerformanceTest extends PerformanceTest {
34     static double[] testValues = { 0,
35                                    0.00000000001,
36                                    0.2e-14,
37                                    0.45,
38                                    123412341234e14,
39                                    987654321e-12,
40                                    234143,
41                                    2.3333444000044e56,
42                                    45.3456 };
43     public void runOp() {
44         DOMImplementation JavaDoc impl = SVGDOMImplementation.getDOMImplementation();
45         String JavaDoc svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
46         Document JavaDoc doc = impl.createDocument(svgNS, "svg", null);
47         final SVGGeneratorContext gc = new SVGGeneratorContext(doc);
48
49         int maxLength = 0;
50         for (int i=0; i<1000; i++) {
51             for (int j=0; j<testValues.length; j++) {
52                 maxLength = Math.max((gc.doubleString(testValues[j])).length(), maxLength);
53             }
54         }
55     }
56 }
57
Popular Tags