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.junit.BaseJDBCTestCase;
26:
27: import java.sql.*;
28:
29: /**
30: * This test test the timing of starting up Derby. It tries to divide the
31: * total time up into reasonable chunks. It's written as a JUnit test but
32: * really can't be automated because the timings are so dependent upon
33: * the exact hardware, operating system and software environment the test
34: * is running in. I just use JUnit because of the convenient framework
35: * it gives me...
36: */
37: public class StartupNewDBTest extends BaseJDBCTestCase {
38: public StartupNewDBTest(String name) {
39: super (name);
40: }
41:
42: public void testNewDB() throws Exception {
43: long startTime = System.currentTimeMillis();
44: System.out.println("Testing startup with a NEW database... "
45: + "All measurements are in milliseconds.");
46:
47: // Load the driver
48: Class driver = Class
49: .forName("org.apache.derby.jdbc.EmbeddedDriver");
50: long currentTime = System.currentTimeMillis();
51: System.out.println("Loading driver: "
52: + (currentTime - startTime));
53:
54: // Create a database
55: startTime = System.currentTimeMillis();
56: Connection conn = DriverManager
57: .getConnection("jdbc:derby:newdb;create=true");
58: currentTime = System.currentTimeMillis();
59: System.out
60: .println("Open connection with creating new database: "
61: + (currentTime - startTime));
62:
63: // Create a table
64: startTime = System.currentTimeMillis();
65: Statement stmt = conn.createStatement();
66: stmt
67: .execute("CREATE TABLE test_table(id integer primary key, "
68: + "last_name varchar(80), first_name varchar(80), "
69: + "mi char(1), address varchar(100), city varchar(80))");
70: currentTime = System.currentTimeMillis();
71: System.out.println("Creating a table: "
72: + (currentTime - startTime));
73: }
74: }
|