01: package org.drools.decisiontable.parser;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import junit.framework.TestCase;
20:
21: /**
22: * @author <a href="mailto:michael.neale@gmail.com"> Michael Neale</a>
23: *
24: * A special test for parsing a large workbook, to see how it scales.
25: *
26: */
27: public class RuleWorksheetParseLargeTest extends TestCase {
28:
29: private long startTimer;
30:
31: private long endTimer;
32:
33: /**
34: * Tests parsing a large spreadsheet into an in memory ruleset. This doesn't
35: * really do anything much at present. Takes a shed-load of memory to dump
36: * out this much XML as a string, so really should think of using a stream
37: * in some cases... (tried StringWriter, but is still in memory, so doesn't
38: * help).
39: *
40: * Stream to a temp file would work: return a stream from that file
41: * (decorate FileInputStream such that when you close it, it deletes the
42: * temp file).... must be other options.
43: *
44: * @throws Exception
45: */
46: public void testLargeWorkSheetParseToRuleset() throws Exception {
47: // Test removed until have streaming sorted in future. No one using Uber Tables just yet !
48: // InputStream stream = RuleWorksheetParseLargeTest.class.getResourceAsStream( "/data/VeryLargeWorkbook.xls" );
49: //
50: // startTimer( );
51: // RuleSheetListener listener = RuleWorksheetParseTest.getRuleSheetListener( stream );
52: // stopTimer( );
53: //
54: // System.out.println( "Time to parse large table : " + getTime( ) );
55: // Ruleset ruleset = listener.getRuleSet( );
56: // assertNotNull( ruleset );
57: /*
58: * System.out.println("Time taken for 20K rows parsed: " + getTime());
59: *
60: * startTimer(); String xml = listener.getRuleSet().toXML();
61: * stopTimer(); System.out.println("Time taken for rendering to XML: " +
62: * getTime());
63: */
64: }
65:
66: private void startTimer() {
67: this .startTimer = System.currentTimeMillis();
68: }
69:
70: private void stopTimer() {
71: this .endTimer = System.currentTimeMillis();
72: }
73:
74: private long getTime() {
75: return this.endTimer - this.startTimer;
76: }
77:
78: }
|