Subject | Driver Speed Tests |
---|---|
Author | Carsten Schäfer |
Post date | 2002-10-14T14:58:26Z |
Hi
I've written a little test class to test the perfomance difference between
Jaybird and Interclient with varchars with character set WIN1252.
This is my db structure:
CREATE DATABASE 'd:\DBTEST.GDB'
USER 'sysdba' PASSWORD 'masterkey'
PAGE_SIZE 4096;
USER 'sysdba' PASSWORD 'masterkey'
PAGE_SIZE 4096;
CREATE TABLE T_TEST1 (
F_TEST1 VARCHAR(250) CHARACTER SET WIN1252,
F_TEST2 VARCHAR(250) CHARACTER SET WIN1252,
F_TEST3 VARCHAR(250) CHARACTER SET WIN1252,
F_TEST4 VARCHAR(250) CHARACTER SET WIN1252,
F_TEST5 VARCHAR(250) CHARACTER SET WIN1252,
F_TEST6 VARCHAR(250) CHARACTER SET WIN1252,
F_TEST7 VARCHAR(250) CHARACTER SET WIN1252,
F_TEST8 VARCHAR(250) CHARACTER SET WIN1252,
F_TEST9 VARCHAR(250) CHARACTER SET WIN1252,
F_TEST10 VARCHAR(250) CHARACTER SET WIN1252
F_TEST1 VARCHAR(250) CHARACTER SET WIN1252,
F_TEST2 VARCHAR(250) CHARACTER SET WIN1252,
F_TEST3 VARCHAR(250) CHARACTER SET WIN1252,
F_TEST4 VARCHAR(250) CHARACTER SET WIN1252,
F_TEST5 VARCHAR(250) CHARACTER SET WIN1252,
F_TEST6 VARCHAR(250) CHARACTER SET WIN1252,
F_TEST7 VARCHAR(250) CHARACTER SET WIN1252,
F_TEST8 VARCHAR(250) CHARACTER SET WIN1252,
F_TEST9 VARCHAR(250) CHARACTER SET WIN1252,
F_TEST10 VARCHAR(250) CHARACTER SET WIN1252
);
And this is my test class:
import interbase.interclient.CharacterEncodings;
import java.sql.*;
import java.util.Properties;
import java.util.Properties;
public class DBTEST {
public static final void dbtest(boolean interclient) {
try {
Properties dbProperties = new Properties();
dbProperties.put("user","sysdba" );
dbProperties.put("password", "masterkey");
dbProperties.put("charSet",CharacterEncodings.Cp1252);
dbProperties.put("lc_ctype", "WIN1252");
Connection con = null;
if (interclient) {
Class.forName("interbase.interclient.Driver");
con = DriverManager.getConnection("jdbc:interbase://localhost/d:/dbtest.gdb", dbProperties);
} else {
Class.forName("org.firebirdsql.jdbc.FBDriver");
con = DriverManager.getConnection("jdbc:firebirdsql://localhost/d:/dbtest.gdb", dbProperties);
}
long start = System.currentTimeMillis();
PreparedStatement insert = con.prepareStatement("insert into t_test1 values (?,?,?,?,?,?,?,?,?,?)");
for (int i= 1;i<=20000;i++) {
insert.setString(1, "ölkkkdsklsdaöd0590945650096945ß945ß46ßsakldsalk9034298428 45290904528420z5928dfldsf"+i);
insert.setString(2, "iowerw8290nvdshdskljkfduiuj-xycäöüäpf3490384jhkffkhdfjgfdhfhdhfh92ß" + i);
insert.setString(3, "dsahjdsalkasä3qpüp3410p4319p341jjludiouaidjilja" + i);
insert.setString(4, "hkdsuuzhdsauidsazhs" + i);
insert.setString(5, "cx,mkjaä3420990320984390843kjghjghjf´ß" + i);
insert.setString(6, "sdkhkjdsau98712098912pk<ä#dsaüaasdääöasööüööösa" + i);
insert.setString(7, "sajkhjasiu7wq987e902ß0pjxycj9fgklgjkgfjkjkdkjldfjkgfjkfdkjfdkjkjgfkjldkjdfkljqei8üoeöälp" + i);
insert.setString(8, "cx.,cxcöö0pßq0ßßq0ßew90idlkdslökiaoödiaopdoixüycü+yxcxpü+y" + i);
insert.setString(9, "12309912031ß13820818308108091238901ß830183208129ß028128hcxkh" + i);
insert.setString(10, "cxklkxyhjsclisauuduiouduosuisauasiu128790132909871239891213209189" + i);
insert.executeUpdate();
}
insert.close();
long ende = System.currentTimeMillis();
System.out.println("Time for insert into test1:"+((ende-start)) );
Statement select = con.createStatement();
ResultSet rs = select.executeQuery("select * from t_test1");
while (rs.next()) {
String s1 = rs.getString("f_test1");
String s2 = rs.getString("f_test2");
String s3 = rs.getString("f_test3");
String s4 = rs.getString("f_test4");
String s5 = rs.getString("f_test5");
String s6 = rs.getString("f_test6");
String s7 = rs.getString("f_test7");
String s8 = rs.getString("f_test8");
String s9 = rs.getString("f_test9");
String s10 = rs.getString("f_test10");
}
rs.close();
select.close();
long ende2 = System.currentTimeMillis();
System.out.println("Time for select from test1:" + ((ende2 - ende)));
con.close();
} catch (ClassNotFoundException e) {
System.err.println("Error:" + e.getMessage());
e.printStackTrace();
} catch (SQLException e2) {
System.err.println("Error:"+e2.getMessage());
e2.printStackTrace();
}
}
public static final void dbtest(boolean interclient) {
try {
Properties dbProperties = new Properties();
dbProperties.put("user","sysdba" );
dbProperties.put("password", "masterkey");
dbProperties.put("charSet",CharacterEncodings.Cp1252);
dbProperties.put("lc_ctype", "WIN1252");
Connection con = null;
if (interclient) {
Class.forName("interbase.interclient.Driver");
con = DriverManager.getConnection("jdbc:interbase://localhost/d:/dbtest.gdb", dbProperties);
} else {
Class.forName("org.firebirdsql.jdbc.FBDriver");
con = DriverManager.getConnection("jdbc:firebirdsql://localhost/d:/dbtest.gdb", dbProperties);
}
long start = System.currentTimeMillis();
PreparedStatement insert = con.prepareStatement("insert into t_test1 values (?,?,?,?,?,?,?,?,?,?)");
for (int i= 1;i<=20000;i++) {
insert.setString(1, "ölkkkdsklsdaöd0590945650096945ß945ß46ßsakldsalk9034298428 45290904528420z5928dfldsf"+i);
insert.setString(2, "iowerw8290nvdshdskljkfduiuj-xycäöüäpf3490384jhkffkhdfjgfdhfhdhfh92ß" + i);
insert.setString(3, "dsahjdsalkasä3qpüp3410p4319p341jjludiouaidjilja" + i);
insert.setString(4, "hkdsuuzhdsauidsazhs" + i);
insert.setString(5, "cx,mkjaä3420990320984390843kjghjghjf´ß" + i);
insert.setString(6, "sdkhkjdsau98712098912pk<ä#dsaüaasdääöasööüööösa" + i);
insert.setString(7, "sajkhjasiu7wq987e902ß0pjxycj9fgklgjkgfjkjkdkjldfjkgfjkfdkjfdkjkjgfkjldkjdfkljqei8üoeöälp" + i);
insert.setString(8, "cx.,cxcöö0pßq0ßßq0ßew90idlkdslökiaoödiaopdoixüycü+yxcxpü+y" + i);
insert.setString(9, "12309912031ß13820818308108091238901ß830183208129ß028128hcxkh" + i);
insert.setString(10, "cxklkxyhjsclisauuduiouduosuisauasiu128790132909871239891213209189" + i);
insert.executeUpdate();
}
insert.close();
long ende = System.currentTimeMillis();
System.out.println("Time for insert into test1:"+((ende-start)) );
Statement select = con.createStatement();
ResultSet rs = select.executeQuery("select * from t_test1");
while (rs.next()) {
String s1 = rs.getString("f_test1");
String s2 = rs.getString("f_test2");
String s3 = rs.getString("f_test3");
String s4 = rs.getString("f_test4");
String s5 = rs.getString("f_test5");
String s6 = rs.getString("f_test6");
String s7 = rs.getString("f_test7");
String s8 = rs.getString("f_test8");
String s9 = rs.getString("f_test9");
String s10 = rs.getString("f_test10");
}
rs.close();
select.close();
long ende2 = System.currentTimeMillis();
System.out.println("Time for select from test1:" + ((ende2 - ende)));
con.close();
} catch (ClassNotFoundException e) {
System.err.println("Error:" + e.getMessage());
e.printStackTrace();
} catch (SQLException e2) {
System.err.println("Error:"+e2.getMessage());
e2.printStackTrace();
}
}
public static void main(String[] args) {
DBTEST.dbtest(false);
}
}
}
With inserts Jaybird is about 30-35% slower than Interclient and with
Selects it's 70-75%.
Any comments ?
gruß
carsten Schäfer