Greetings,

In working with H2's Automatic Mixed Mode, I have formed the following
performance-rating application (See below). Would you be able to
direct me into forming my application into an overall performance tool
or contribution? I would like to extend the application this week as
one of the milestones, but not quite sure which direction it could
take. It currently times the execution of many inserts & deletes with
the performance being worse on server connections (as documented).

=============
Connection1
=============
public class MyAutoMixedMode {
    public static void main(String... args) throws Exception {
        DeleteDbFiles.execute("~", "test", true);
        Class.forName("org.h2.Driver");
        Connection conn = DriverManager.getConnection("jdbc:h2:~/
test;AUTO_SERVER=TRUE");
        Statement stat = conn.createStatement();
        stat.execute("create table test(id int primary key, name
varchar(255))");
        long startTime = System.currentTimeMillis();
        long endTime;
        for(int i=0; i<2000; i++){
                stat.execute("insert into test values(1, 'Hello')");
                stat.execute("delete from test where id = '1' ");
        }
        endTime = System.currentTimeMillis();
        System.out.println("Performance With Connection-1: " +
(endTime-startTime) );
        stat.execute("insert into test values(1, 'Hello')");
        ResultSet rs;
        rs = stat.executeQuery("select * from test");
        while (rs.next()) {
            System.out.println(rs.getString("name"));
        }
        stat.close();
        try
        {
           Thread.sleep(30000);
        }
        catch (InterruptedException e)
        {
           // Resume execution
        }

        conn.close();
        System.out.println("Connection1 Closed.");
    }

}
=============
Connection2...3...etc
=============
public class MyAutoMixedMode2 {
    public static void main(String... args) throws Exception {
        Class.forName("org.h2.Driver");
        Connection conn = DriverManager.getConnection("jdbc:h2:~/
test;AUTO_SERVER=TRUE");
        Statement stat = conn.createStatement();
        long startTime = System.currentTimeMillis();
        long endTime;
        for(int i=0; i<2000; i++){
                stat.execute("insert into test values(2, 'World')");
                stat.execute("delete from test where id = '2' ");
        }
        endTime = System.currentTimeMillis();
        System.out.println("Performance With Connection-2: " +
(endTime-startTime) );
        stat.execute("insert into test values(2, 'World')");
        ResultSet rs;
        rs = stat.executeQuery("select * from test");
        while (rs.next()) {
            System.out.println(rs.getString("name"));
        }
        stat.close();
        conn.close();
        System.out.println("Connection2 Closed.");
    }


Thanks,
Michael




> Please tell me if that works for you!
>
> Regards,
> Thomas

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to