Fixed immediate dependence on DBI
[dbsrgits/DBM-Deep.git] / t_attic / 36_verybighash.t
1 # This test was contributed by Fedor Soreks, Jan 2007.
2
3 use strict;
4 use Test::More;
5
6 plan skip_all => "You must set \$ENV{LONG_TESTS} >= 2 to run the superlong tests"
7     unless $ENV{LONG_TESTS} && $ENV{LONG_TESTS} >= 2;
8
9 use Test::Deep;
10 use t::common qw( new_fh );
11
12 plan tests => 2;
13
14 use_ok( 'DBM::Deep' );
15
16 diag "This test can take up to several hours to run. Please be VERY patient.";
17
18 my ($fh, $filename) = new_fh();
19 my $db = DBM::Deep->new(
20     file => $filename,
21     type => DBM::Deep->TYPE_HASH,
22 );
23
24 my $gigs = 2;
25
26 ##
27 # put/get many keys
28 ##
29 my $max_keys = 4_000_000;
30 my $max_record_keys = 10;
31
32 for my $key_no ( 0 .. $max_keys ) {
33     for my $rec_no ( 0 .. $max_record_keys ) {
34         $db->{"key_$key_no"}{"rec_key_$rec_no"} = "rec_val_$rec_no";
35     }
36
37     my $s = -s $filename;
38     print "$key_no: $s\n";
39
40     if ( $s > $gigs * 2**30) {
41         fail "DB file ($filename) size exceeds $gigs GB";
42         exit;
43     }
44 }
45
46 ok( 1, "We passed the test!" );