use strict;
use warnings;

use DBI;

use Benchmark qw(:all) ;


my $database = "books.db";
# my $database = ":memory:";
# メモリ上のデータベースへ接続
my $dbh = DBI->connect("dbi:SQLite:dbname=$database");

my $t = timeit($ARGV[0],
sub {
my $title = sprintf("Perl%05d",rand(10000));
# select文の実行
my $sth = $dbh->prepare("select * from books where title='$title';");
$sth->execute;

# 各行のフェッチ
while (my @row = $sth->fetchrow_array) {
    # 各行を出力
    # print join(', ', @row), "\n";
}
}); 

print timestr($t);

# データベースの切断
$dbh->disconnect;


