01: /*
02:
03: Derby - Class org.apache.derbyTesting.functionTests.test.perf.StartupTest
04:
05: Licensed to the Apache Software Foundation (ASF) under one
06: or more contributor license agreements. See the NOTICE file
07: distributed with this work for additional information
08: regarding copyright ownership. The ASF licenses this file
09: to you under the Apache License, Version 2.0 (the
10: "License"); you may not use this file except in compliance
11: with the License. You may obtain a copy of the License at
12:
13: http://www.apache.org/licenses/LICENSE-2.0
14:
15: Unless required by applicable law or agreed to in writing,
16: software distributed under the License is distributed on an
17: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18: KIND, either express or implied. See the License for the
19: specific language governing permissions and limitations
20: under the License.
21: */
22:
23: package org.apache.derbyTesting.functionTests.tests.perf;
24:
25: import org.apache.derbyTesting.functionTests.util.JarUtil;
26: import org.apache.derbyTesting.junit.BaseJDBCTestCase;
27:
28: import java.sql.*;
29:
30: /**
31: * This test test the timing of starting up Derby. It tries to divide the
32: * total time up into reasonable chunks. It's written as a JUnit test but
33: * really can't be automated because the timings are so dependent upon
34: * the exact hardware, operating system and software environment the test
35: * is running in. I just use JUnit because of the convenient framework
36: * it gives me...
37: */
38: public class StartupExistingDBTest extends BaseJDBCTestCase {
39: public StartupExistingDBTest(String name) {
40: super (name);
41: }
42:
43: public void testExistingDB() throws Exception {
44: JarUtil.unjar("existingDb.jar", null);
45:
46: long startTime = System.currentTimeMillis();
47: System.out
48: .println("Testing startup with an EXISTING database... "
49: + "All measurements are in milliseconds.");
50:
51: // Load the driver
52: Class driver = Class
53: .forName("org.apache.derby.jdbc.EmbeddedDriver");
54: long currentTime = System.currentTimeMillis();
55: System.out.println("Loading driver: "
56: + (currentTime - startTime));
57:
58: // Use an existing DB. This is copied over by the harness
59: startTime = System.currentTimeMillis();
60: Connection conn = DriverManager
61: .getConnection("jdbc:derby:../existingDb");
62: currentTime = System.currentTimeMillis();
63: System.out.println("Open connection with existing database: "
64: + (currentTime - startTime));
65:
66: // Create a table
67: startTime = System.currentTimeMillis();
68: Statement stmt = conn.createStatement();
69: stmt
70: .execute("CREATE TABLE test_table(id integer primary key, "
71: + "last_name varchar(80), first_name varchar(80), "
72: + "mi char(1), address varchar(100), city varchar(80))");
73: currentTime = System.currentTimeMillis();
74: System.out.println("Creating a table: "
75: + (currentTime - startTime));
76: }
77: }
|