// Copyright InterBase Software Corporation, 1998. // Written by inprise.interbase.interclient.r&d.PaulOstler :-) /** * Portable performance test suite for InterClient or any other JDBC driver. *
* IMPORTANT STEPS BEFORE RUNNING THIS TEST *
* For InterBase, manually create test.gdb in the directory of your choice as follows: *
* Some database products, like Oracle, manage their own filespace * so skip this step for such products. *
main()
) external to this
* PerformanceTests
library.
* Do not edit the default values in the
* PerformanceTest
source.
* Rather, edit a copy of class interbase.interclient.tests.ExampleTests
.
* or copy the ExampleTests
program and modify its source.
* You may want to change the package name (interbase.interclient.tests)
* on the first line of your copy of the ExampleTests
* source file to the name
* of your choice, making sure
* the package name matches the new directory location of your test
* program relative to your class path,
* then compile the new program source.
*
* Configure variables for the
* URLs, drivers, and test control switches in ExampleTests
.
*
* You must manually configure ODBC and BDE
* data-source names for test.gdb using the ODBC or BDE
* configuration utilities. For consistency, use
* ODBC and BDE alias names as suggested by the defaults
* of the various configuration variables in ExampleTests
.
* The ODBC configuration utiltity
* can usually be found in the NT control panel.
* The BDE Administrator can be found in the DataGateway program group.
*
ExampleTests
.
* Also, make sure DataGateway.zip, InterClient.jar,
* and any other driver to test are in a library class path for your project.
* * The default value is null, which means output will be written to System.out. **/ public static String outputFileName = null; /** * An array of database engines, usernames, passwords, URLs, and drivers you wish to test. *
* Each element in the array consists of a tuple
* { engineName, username, password, URL, driverClassName }
.
* The engine name is needed
* to construct dbms-dependent SQL. Valid engine names are
* "interbase", "oracle", etc...
* Some drivers, such as DataGateway, can be used against
* different engines (known as category 3 drivers).
*
* Here are some example client/server tuples that could be tested * The remote hostname may be set to localhost to test client/server in loopback mode. *
* PerformanceTests.driversToTest = new String[][] { * // *** Client/server URLs *** * // JDBC-ODBC bridge used remotely (uses native dbms client api and dbms net protocol) * { "interbase", * "sysdba", * "masterkey", * "jdbc:odbc:clientServerTest", * "sun.jdbc.odbc.JdbcOdbcDriver" } * // InterClient (uses custom client api and remote protocol (RP)) * ,{ "interbase", * "sysdba", * "masterkey", * "jdbc:interbase://hostname/d:/databases/test.gdb", * "interbase.interclient.Driver" } * // Datagateway Broker (uses custom client api and remote protocol (RP)) * ,{ "interbase", * "sysdba", * "masterkey", * "jdbc:BorlandBroker://hostname/localTest", * "borland.jdbc.Broker.RemoteDriver" } * // Datagateway bridge used remotely (uses native dbms client api and RP) * ,{ "interbase", * "sysdba", * "masterkey", * "jdbc:BorlandBridge:clientServerTest", * "borland.jdbc.Bridge.LocalDriver" } * // Sybase jConnect (uses custom client api, but uses TDS remote protocol) * ,{ "sqlanywhere", * "dba", * "sql", * "jdbc:sybase:Tds:hostname:4444/d:\\sqlany50\\sademo.db", * "com.sybase.jdbc.SybDriver" } * // Symantec dbAnywhere * ,{ "sqlanywhere", * "dba", * "sql", * "jdbc:dbaw://hostname:8889/Sybase_SQLANY/Sademo/Sademo", * "symantec.itools.db.jdbc.Driver" } * // Oracle Thin Driver (uses custom client api, but uses Oracle remote protocol?) * ,{ "oracle", * "user", * "password", * "jdbc:oracle:thin:@hostname:1521:ORCL", * "oracle.jdbc.driver.OracleDriver" } * // Solid Driver uses Solid protocol * ,{ "solid", * "sysdba", * "masterkey", * "jdbc:solid://hostname:1313/sysdba/masterkey", * "solid.jdbc.SolidDriver" } * // * // *** Local URLs follow (not client/server) *** * // Datagateway bridge used locally * ,{ "interbase", * "sysdba", * "masterkey", * "jdbc:BorlandBridge:localTest", * "borland.jdbc.Bridge.LocalDriver" } * // JDBC-ODBC bridge used locally * ,{ "interbase", * "sysdba", * "masterkey", * "jdbc:odbc:localTest" * "sun.jdbc.odbc.JdbcOdbcDriver" } * }; ***/ public static String[][] driversToTest = null; // ************************************************* // *** Configurable test control switches follow *** // *** (ie. what to test and what not to test). *** // *** Modify values thru an external application rather than *** // *** modifying the default values as set here. *** // ************************************************* // *** Toggles for performance suites *** public static boolean testMetaData = false; // exhaustive database metadata extraction public static boolean testStrings = false; // various CHAR(n) tests public static boolean testBLObs = false; // various BLOb tests public static boolean testNumbers = false; // various numeric data public static boolean testDates = false; // Dates, Times, and Timestamps public static boolean testProcedures = false; // Stored procedures public static boolean test1ByteBlobs = false; // uses dataSize/1 rows public static boolean test10ByteBlobs = false; // uses dataSize/10 rows public static boolean test100ByteBlobs = false; // uses dataSize/100 rows public static boolean test1000ByteBlobs = false; // uses dataSize/1000 rows public static boolean test10000ByteBlobs = false; // uses dataSize/10000 rows public static boolean test100000ByteBlobs = false; // uses dataSize/100000 rows public static boolean test1CharStrings = false; // most time consuming public static boolean test10CharStrings = false; public static boolean test100CharStrings = false; public static boolean test1000CharStrings = false; public static boolean test10000CharStrings = false; // least time consuming /** * Size of bulk data loads for testing. *
* testDataSize
indicates how many bytes are inserted or selected for each test.
* For example, if the testDataSize
= 100,000, then the 1-byte blob test will
* insert 100,00 rows of 1-byte blobs, but the 100,000-byte blob test will
* insert only a single row. Decreasing dataSize
will decrease the time
* required to run the performance tests.
*
* Default value is 1,000.
* It is recommended to always make dataSize divisible by 1,000.
**/
public static int testDataSize = 1000; // make it divisible by 1,000
/**
* See InterClient API reference for Connection.setAutoCommit()
.
*
* Default is false.
* @see interbase.interclient.Connection#setAutoCommit
**/
public static boolean enableAutoCommit = false;
/**
* Direct the driver manager log stream to ouputFileName
.
* See JavaSoft API reference for DriverManager.setLogStream()
.
*
* Default is false.
* @see java.sql.DriverManager#setLogStream
**/
public static boolean enableDriverManagerLogStream = false;
/**
* Character set name, see InterClient API reference for class
* interbase.interclient.ConnectionProperties
for mappings
* to InterBase character sets.
*
* Default is null which means to use the driver defaults. * @see interbase.interclient.ConnectionProperties **/ public static String characterSet = null; /** * This is the character to use to construct test strings. * For example, if test100chars is enabled, then a test string * of 100 characters will be created using this character. *
* Default is 'X'.
* @see #characterSet
**/
public static char character = 'X';
// **********************************************
// *** End of Configurables *********************
// **********************************************
// *** specifies the number of bytes per row in NUMBER_TABLE ***
// *** set below with table declaration for number tests ***
private static int numberBytesPerRecord__;
// *** String data to be inserted and selected from test database ***
private static String s1char__ = null;
private static String s10chars__ = null;
private static String s100chars__ = null;
private static String s1000chars__ = null;
private static String s10000chars__ = null;
// *** Blob data to be inserted and selected from test database ***
private static byte[] b1byte__ = null;
private static byte[] b10bytes__ = null;
private static byte[] b100bytes__ = null;
private static byte[] b1000bytes__ = null;
private static byte[] b10000bytes__ = null;
private static byte[] b100000bytes__ = null;
// *** Performance metric variables ***
private static long startTime__, endTime__, elapsedTime__;
// *** The engine currently being tested, this is used to determine
// *** the variant of SQL to use.
// *** Engine names are passed in as part of the urlsToTest array.
private static String engine__;
// *** JDBC global object declarations ***
private static java.sql.Driver d__ = null;
private static java.sql.Connection c__ = null;
private static java.sql.Statement s__ = null;
private static java.sql.PreparedStatement ps__ = null;
private static java.sql.ResultSet rs__ = null;
private static java.util.Properties properties__ = null;
private static String user__ = null;
private static String password__ = null;
private static String url__ = null;
// *** Print stream for writing results ***
private static java.io.PrintStream printStream__ = null;
/**
* Run the performance tests under the configuration as set
* by the public configuration variables.
* Results are written to outputFileFile
.
**/
synchronized static public void run ()
{
// this forces jdbc objects to be closed before
// this java application exits.
System.runFinalizersOnExit (true);
if (outputFileName == null) {
printStream__ = System.out; // System.out is the default
}
else {
try {
printStream__ =
new java.io.PrintStream (new java.io.FileOutputStream (outputFileName),
true); // auto-flush
}
catch (java.io.IOException e) {
System.out.println ("Couldn't open print stream to " + outputFileName +
"Aborting tests...");
System.exit (1);
}
}
showPerformanceTuningVariables ();
try {
int i;
populateStaticData ();
if (enableDriverManagerLogStream)
java.sql.DriverManager.setLogStream (printStream__);
// *** Load all available drivers from your class path ***
for (i=0; i