LCOV - code coverage report
Current view: top level - home/olly/git/atia-xapian/xapian-core/tests - api_scalability.cc (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core r Lines: 12 12 100.0 %
Date: 2011-08-21 Functions: 2 2 100.0 %
Branches: 2 2 100.0 %

           Branch data     Line data    Source code
       1                 :            : /** @file api_scalability.cc
       2                 :            :  * @brief Tests of scalability.
       3                 :            :  */
       4                 :            : /* Copyright (C) 2008,2009 Olly Betts
       5                 :            :  *
       6                 :            :  * This program is free software; you can redistribute it and/or
       7                 :            :  * modify it under the terms of the GNU General Public License as
       8                 :            :  * published by the Free Software Foundation; either version 2 of the
       9                 :            :  * License, or (at your option) any later version.
      10                 :            :  *
      11                 :            :  * This program is distributed in the hope that it will be useful,
      12                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14                 :            :  * GNU General Public License for more details.
      15                 :            :  *
      16                 :            :  * You should have received a copy of the GNU General Public License
      17                 :            :  * along with this program; if not, write to the Free Software
      18                 :            :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
      19                 :            :  * USA
      20                 :            :  */
      21                 :            : 
      22                 :            : #include <config.h>
      23                 :            : 
      24                 :            : #include "api_scalability.h"
      25                 :            : 
      26                 :            : #include "apitest.h"
      27                 :            : #include "cputimer.h"
      28                 :            : #include "scalability.h"
      29                 :            : #include "testsuite.h"
      30                 :            : #include "testutils.h"
      31                 :            : 
      32                 :            : #include <xapian.h>
      33                 :            : 
      34                 :            : using namespace std;
      35                 :            : 
      36                 :            : static double
      37                 :         20 : bigoaddvalue1_helper(unsigned num_values)
      38                 :            : {
      39                 :         20 :     Xapian::WritableDatabase db = get_writable_database();
      40                 :            : 
      41                 :         20 :     Xapian::Document doc;
      42         [ +  + ]:     550020 :     for (unsigned i = 0; i < num_values; ++i) {
      43                 :     550000 :         doc.add_value(i, "moo");
      44                 :            :     }
      45                 :            : 
      46                 :         20 :     CPUTimer timer;
      47                 :            : 
      48                 :         20 :     db.add_document(doc);
      49                 :         20 :     db.commit();
      50                 :            : 
      51                 :         20 :     return timer.get_time();
      52                 :            : }
      53                 :            : 
      54                 :         10 : DEFINE_TESTCASE(bigoaddvalue1, writable) {
      55                 :            :     // O(n*n) is bad, but O(n*log(n)) is acceptable.
      56                 :         10 :     test_scalability(bigoaddvalue1_helper, 5000, O_N_LOG_N);
      57                 :         10 :     return true;
      58                 :            : }

Generated by: LCOV version 1.8