Program1:
#!/usr/bin/perl -w
use DBI qw(:sql_types);
use DBD::TimesTen qw(:sql_isolation_options);
############
### Remove any old trace files
unlink 'dbitrace.log' if -e 'dbitrace.log';
############
my $I=0;
my $count;
while ( $I <= 50 ) {
if (fork) {
print "Fork $I\n";
}else{
$before = time();
DBI->trace( 2, 'dbitrace.log' );
my $dbh = DBI->connect('DBI:TimesTen:DSN=c1;TCP_PORT=17003', undef,undef ,{
RaiseError => 1,
AutoCommit => 1
}
)or die $DBI::errstr;
my $dbh2 = DBI->connect('DBI:TimesTen:DSN=c2;TCP_PORT=17003', undef,undef ,{
RaiseError => 1,
AutoCommit => 1
}
)
or die $DBI::errstr;
for ($count = 0 ;$count < 1000; $count++) {
my $range = 10000000000; my $range2 = 10000000000000; my $ran=int(rand($range)); my $ran2=int(rand($range2));
my $sql = qq{ INSERT INTO TIMESTEN_TMP.TEMP_DATA3 VALUES ( $ran, 'TEST', 'TEST' ) };
my $sql2 = qq{ INSERT INTO TIMESTEN_TMP.TEMP_DATA3 VALUES ( $ran2, 'TEST2', 'TEST2' ) };
my $sth = $dbh->prepare( $sql );
my $sth2 = $dbh->prepare( $sql2 );
$sth->execute();
$sth2->execute();
$sth->finish();
$sth2->finish();
}
$dbh->disconnect();
$dbh2->disconnect();
$after = time();
$t = $after - $before;
print "---------------\n";
print "Timing:$t\n";
print "---------------\n\n\n";
exit (0);
}
$I++;
}
Program2:
#!/usr/bin/perl -w
use DBI qw(:sql_types);
use DBD::TimesTen qw(:sql_isolation_options);
my $I=0;
my $count;
while ( $I <= 10 ) { if (fork) { print "Fork $I\n"; }else{ $before = time(); my $dbh = DBI->connect('DBI:TimesTen:DSN=cc1;TCP_PORT=17003', undef,undef
)
or die $DBI::errstr;
my $dbh2 = DBI->connect('DBI:TimesTen:DSN=cc2;TCP_PORT=17003', undef,undef
)
or die $DBI::errstr;
for ($count = 0 ;$count < 500; $count++) {
my $range = 10000;
my $range2 = 1000;
my $ran=int(rand($range));
my $ran2=int(rand($range2));
my $sql = qq{ SELECT count(id) FROM TIMESTEN_TMP.TEMP_DATA5 where id = $ran }; my $sql2 = qq{ SELECT count(id) FROM TIMESTEN_TMP.TEMP_DATA5 where id = $ran2}; my $sth = $dbh->prepare( $sql );
my $sth2 = $dbh->prepare( $sql2 );
$sth->execute();
$sth2->execute();
my $row = $sth->rows();
$ref = $sth->fetchall_arrayref;
my $row2 = $sth2->rows();
$ref2 = $sth2->fetchall_arrayref;
foreach $row ( @{$ref} ) {
print "@$row\n";
}
foreach $row2 ( @{$ref2} ) {
print "@$row2\n";
}
$sth->finish();
$sth2->finish();
}
$dbh->disconnect();
$dbh2->disconnect();
$after = time();
$t = $after - $before;
print "---------------\n";
print "Timing:$t\n";
print "---------------\n\n\n";
exit (0);
}
$I++;
}
...
Wednesday, October 17, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment