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 $create_table = "create table books (" .
                       "title," .
                       "author" .
                   ");";
$dbh->do($create_table);

# インデックスの作成
my $create_index = "create index booksindex on books (" .
                       "title," .
                       "author" .
                   ");";
$dbh->do($create_index);



# insert文の実行
my $title = 'Perl00000';
my $author = 'Kono00000';

my $t = timeit($ARGV[0],
    sub {
	$dbh->do("insert into books (title, author) values ('".
		     $title++."', '".$author++."');");
    });

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

print timestr($t);


