1 /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 // vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
3 #ident "$Id$"
4 /*======
5 This file is part of PerconaFT.
6 
7 
8 Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
9 
10     PerconaFT is free software: you can redistribute it and/or modify
11     it under the terms of the GNU General Public License, version 2,
12     as published by the Free Software Foundation.
13 
14     PerconaFT is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17     GNU General Public License for more details.
18 
19     You should have received a copy of the GNU General Public License
20     along with PerconaFT.  If not, see <http://www.gnu.org/licenses/>.
21 
22 ----------------------------------------
23 
24     PerconaFT is free software: you can redistribute it and/or modify
25     it under the terms of the GNU Affero General Public License, version 3,
26     as published by the Free Software Foundation.
27 
28     PerconaFT is distributed in the hope that it will be useful,
29     but WITHOUT ANY WARRANTY; without even the implied warranty of
30     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31     GNU Affero General Public License for more details.
32 
33     You should have received a copy of the GNU Affero General Public License
34     along with PerconaFT.  If not, see <http://www.gnu.org/licenses/>.
35 ======= */
36 
37 #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved."
38 
39 #include "test.h"
40 #include <toku_time.h>
41 
42 static const char *fname = TOKU_TEST_FILENAME;
43 
44 static const enum toku_compression_method compression_method = TOKU_DEFAULT_COMPRESSION_METHOD;
45 
46 static TOKUTXN const null_txn = 0;
47 
test3(int nodesize,int basementnodesize,int count)48 static void test3 (int nodesize, int basementnodesize, int count) {
49     FT_HANDLE t;
50     int r;
51     struct timeval t0,t1;
52     int i;
53     CACHETABLE ct;
54 
55     toku_cachetable_create(&ct, 0, ZERO_LSN, nullptr);
56     gettimeofday(&t0, 0);
57     unlink(fname);
58     r = toku_open_ft_handle(fname, 1, &t, nodesize, basementnodesize, compression_method, ct, null_txn, toku_builtin_compare_fun);
59     assert(r==0);
60     for (i=0; i<count; i++) {
61 	char key[100],val[100];
62 	DBT k,v;
63 	snprintf(key,100,"hello%d",i);
64 	snprintf(val,100,"there%d",i);
65 	toku_ft_insert(t, toku_fill_dbt(&k, key, 1+strlen(key)), toku_fill_dbt(&v, val, 1+strlen(val)), null_txn);
66     }
67     r = toku_verify_ft(t); assert(r==0);
68     r = toku_close_ft_handle_nolsn(t, 0);        assert(r==0);
69     toku_cachetable_close(&ct);
70 
71     gettimeofday(&t1, 0);
72     {
73 	double diff = toku_tdiff(&t1, &t0);
74 	if (verbose) printf("serial insertions: blocksize=%d %d insertions in %.3f seconds, %.2f insertions/second\n", nodesize, count, diff, count/diff);
75     }
76 }
77 
ft_blackbox_test(void)78 static void ft_blackbox_test (void) {
79     if (verbose) printf("test3 slow\n");
80 
81     test3(2048, 512, 1<<15);
82     if (verbose) printf("test3 fast\n");
83 
84     //if (verbose) toku_pma_show_stats();
85 
86     test3(1<<15, 1<<12, 1024);
87     if (verbose) printf("test3 fast\n");
88 
89     test3(1<<18, 1<<15, 1<<20);
90 
91 
92 //    test3(1<<19, 1<<16, 1<<20);
93 
94 //    test3(1<<20, 1<<17, 1<<20);
95 
96 //    test3(1<<20, 1<<17, 1<<21);
97 
98 //    test3(1<<20, 1<<17, 1<<22);
99 
100 }
101 
102 int
test_main(int argc,const char * argv[])103 test_main (int argc , const char *argv[]) {
104     default_parse_args(argc, argv);
105 
106     ft_blackbox_test();
107 
108     if (verbose) printf("test ok\n");
109     return 0;
110 }
111