Re: JAVA vs PERL : PERL wins to postgreSQL

Поиск
Список
Период
Сортировка
От andy
Тема Re: JAVA vs PERL : PERL wins to postgreSQL
Дата
Msg-id 3B94DC41.9ADA25DA@exkom.co.za
обсуждение исходный текст
Ответ на JAVA vs PERL : PERL wins to postgreSQL  (andy <andy@exkom.co.za>)
Список pgsql-jdbc
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; i<last ; i++) {
             for (int p=0; p<last ; 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();
      }
}
}

/*
   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 = 10000;
     int res = stmt.executeUpdate("delete from junk");

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

         for (int i=0; i<last ; 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 = 10000;

$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"
**/

Вложения

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: "Alexander Troppmann"
Дата:
Сообщение: Troubles using German Umlauts with JDBC
Следующее
От: glint22@globalinxs.de
Дата:
Сообщение: Troubles using German Umlauts wit JDBC driver