LCOV - code coverage report
Current view: top level - harness - scalability.cc (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core r Lines: 11 12 91.7 %
Date: 2011-08-21 Functions: 1 1 100.0 %
Branches: 3 10 30.0 %

           Branch data     Line data    Source code
       1                 :            : /** @file scalability.cc
       2                 :            :  * @brief Test how an operation scales.
       3                 :            :  */
       4                 :            : /* Copyright (C) 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 USA
      19                 :            :  */
      20                 :            : 
      21                 :            : #include <config.h>
      22                 :            : 
      23                 :            : #include "scalability.h"
      24                 :            : 
      25                 :            : #include "cputimer.h"
      26                 :            : #include "testsuite.h"
      27                 :            : 
      28                 :            : void
      29                 :         10 : test_scalability(double (*func)(unsigned), unsigned n, double threshold)
      30                 :            : {
      31                 :            :     double time1;
      32                 :            :     // Increase the number of tests until we take a reliably measurable amount
      33                 :            :     // of time.
      34         [ -  + ]:         10 :     do {
      35                 :         10 :        time1 = func(n);
      36                 :         10 :        tout << "Test with " << n << " repetitions took " << time1 << " secs\n";
      37                 :         10 :        unsigned n_new = n * 10;
      38         [ -  + ]:         10 :        if (n_new < n)
      39         [ #  # ]:          0 :            SKIP_TEST("Can't count enough repetitions to be able to time test");
      40                 :         10 :        n = n_new;
      41                 :            :     } while (time1 <= 0.001);
      42                 :            : 
      43                 :         10 :     double time10 = func(n);
      44                 :         10 :     tout << "Test with " << n << " repetitions took " << time10 << " secs\n";
      45                 :            : 
      46   [ -  +  #  # ]:         10 :     TEST_REL(time10,<,time1 * threshold);
      47                 :         10 : }

Generated by: LCOV version 1.8