Re: [JDBC] JAVA vs PERL : PERL wins to postgreSQL

2001-09-04 Thread andy

To all those who responded ,
Thanks for your response,

I have attached the test programs that I used in the form of text files. The
contents should be self evident. Please have a look and comment.

I used j2sdk1.3.1 down load to linux machine from sun.com as my java platform
and
And  perl, v5.6.0 built for i386-linux.
 The PostgreSQL driver for perl came from www.perl.org
  The postgreSQL driver in jdbc7.0-1.2.jar


Barry Lind wrote:

 Andy,

 I would be interesting in knowing what version you did this test on,
 what platform, and most importantly which JDK (and if the Sun JDK which
 JVM: classic, hotspot client, hotspot server).

 thanks,
 --Barry

 andy wrote:
  Hi,
 
  I ran a few bench marks on JAVA writing to a postgreSQL table using  and
  found that for the same number of records added to the table as a
  similar PERL routine the following results :
   PERL 39 seconds : JAVA 45 Seconds.
  In a similar experiment where PERL and JAVA did treir output to the
  screen and not to a table,
 
  JAVA took 3 seconds and PERL 310 Seconds.
  My conclusion is that the database driver to postgreSQL is still far
  from efficient in the JAVA implementation.
 
  Both tests were run on the same computer.
 
  I would appreciate your comments and suggestions.
  Andy Sewell
 
 
  ---(end of broadcast)---
  TIP 5: Have you checked our extensive FAQ?
 
  http://www.postgresql.org/users-lounge/docs/faq.html
 
 


/*
   Java bench mark against perl count to 100 000 000
*/
import java.io.*;
import java.util.*;

public class lp{
  
  public lp() throws ClassNotFoundException, FileNotFoundException, IOException
  {
 int last = 1000;

 GregorianCalendar day = new GregorianCalendar();
 String time = day.getTime().toString();
 int k=0;
 for (int i=0; ilast ; i++) {
 for (int p=0; plast ; p++) {k=1+p;System.out.println(k);}
  } 
  
  GregorianCalendar day1 = new GregorianCalendar();
  String time2 = day1.getTime().toString();
  System.out.println(time);
  System.out.println(time2 + \n + k);
 
   
  }
  
public static void main(String[] args) {
  try {
lp test = new lp();
  } 
   catch (Exception ex) {
 System.err.println(Exception : + ex);
 ex.printStackTrace();
  }
}
}


 lp.pl

/*
   Java equivalent
*/
import java.io.*;
import java.sql.*;
import java.util.*;

public class pg{
  Connection conn;
  Statement  stmt;
  
  public pg() throws ClassNotFoundException, FileNotFoundException, IOException, 
SQLException
  {
 Class.forName(org.postgresql.Driver);
 conn = DriverManager.getConnection(jdbc:postgresql:exkom, andy, );
 conn.setAutoCommit(true);
 stmt = conn.createStatement();
 int last = 1;
 int res = stmt.executeUpdate(delete from junk);

 GregorianCalendar day = new GregorianCalendar();
 String time = day.getTime().toString();

 for (int i=0; ilast ; i++) {
  // try {
 res =  stmt.executeUpdate(insert into junk values( + i + ));
 
//} catch (SQLException e) {
//  System.out.println(e);
//}
  } 
  
  GregorianCalendar day1 = new GregorianCalendar();
  String time2 = day1.getTime().toString();
//String time3 = day.getTime().toString();
  System.out.println(time);
  System.out.println(time2);
//System.out.println(time3);

//res.close();
  stmt.close();
  conn.close();
 
   
  }
  
public static void main(String[] args) {
  try {
pg test = new pg();
  } 
   catch (Exception ex) {
 System.err.println(Exception : + ex);
 ex.printStackTrace();
  }
}
}

/**


$conn = Pg::connectdb(dbname=exkom);
die $conn-errorMessage unless PGRES_CONNECTION_OK eq $conn-status;

# print Enter a state code :;
# $state_code = STDIN;

# chomp $state_code;
$result = $conn-exec(delete from junk);
$end = 1;

$t0 = new Benchmark;

for ($i=1; $i  $end; $i++) {
 $result = $conn-exec(insert into junk values($i));
}

$t1 = new Benchmark;
$td = timediff($t1, $t0);
print  the $end records took :, timestr($td) , \n
**/
 pg.pl


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



[JDBC] JAVA vs PERL : PERL wins to postgreSQL

2001-09-03 Thread andy

Hi,

I ran a few bench marks on JAVA writing to a postgreSQL table using  and
found that for the same number of records added to the table as a
similar PERL routine the following results :
 PERL 39 seconds : JAVA 45 Seconds.
In a similar experiment where PERL and JAVA did treir output to the
screen and not to a table,

JAVA took 3 seconds and PERL 310 Seconds.
My conclusion is that the database driver to postgreSQL is still far
from efficient in the JAVA implementation.

Both tests were run on the same computer.

I would appreciate your comments and suggestions.
Andy Sewell


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html