1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
# $Id$
use strict;
use lib 't/lib';
use lib 't/lib/cached';
require 't/lib/db-common.pl';
use Benchmark qw(:all);
use User;
setup_dbs({
global => [ qw( user ) ],
});
my $how_many = shift || 10_000;
my @recipes;
=cut
for (1..$how_many) {
my $recipe = Recipe->new;
$recipe->title("recipe $_");
$recipe->insert;
}
=cut
## generate some data
my $data = { map { $_ => $_ } @{ User->properties->{columns} } };
$data->{user_id} = int rand 100000;
my @users;
my $i;
timethis( $how_many, sub {
push @users, User->inflate({ columns => $data });
});
END { teardown_dbs(qw( global )); }
|