queso-0.53.0
perf.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------
2 // File: perf.cpp
3 // Programmer: Sunil Arya and David Mount
4 // Description: Methods for performance stats
5 // Last modified: 01/27/10 (Version 1.1.2)
6 //----------------------------------------------------------------------
7 // Copyright (c) 1997-2010 University of Maryland and Sunil Arya and
8 // David Mount. All Rights Reserved.
9 //
10 // This software and related documentation is part of the Approximate
11 // Nearest Neighbor Library (ANN). This software is provided under
12 // the provisions of the Lesser GNU Public License (LGPL). See the
13 // file ../ReadMe.txt for further information.
14 //
15 // The University of Maryland (U.M.) and the authors make no
16 // representations about the suitability or fitness of this software for
17 // any purpose. It is provided "as is" without express or implied
18 // warranty.
19 //----------------------------------------------------------------------
20 // History:
21 // Revision 0.1 03/04/98
22 // Initial release
23 // Revision 1.0 04/01/05
24 // Changed names to avoid namespace conflicts.
25 // Added flush after printing performance stats to fix bug
26 // in Microsoft Windows version.
27 // Revision 1.1.2 01/27/10
28 // Fixed minor compilation bugs for new versions of gcc
29 //----------------------------------------------------------------------
30 
31 #include <ANN/ANN.h> // basic ANN includes
32 #include <ANN/ANNperf.h> // performance includes
33 
34 using namespace std; // make std:: available
35 
36 //----------------------------------------------------------------------
37 // Performance statistics
38 // The following data and routines are used for computing
39 // performance statistics for nearest neighbor searching.
40 // Because these routines can slow the code down, they can be
41 // activated and deactiviated by defining the PERF variable,
42 // by compiling with the option: -DPERF
43 //----------------------------------------------------------------------
44 
45 //----------------------------------------------------------------------
46 // Global counters for performance measurement
47 //----------------------------------------------------------------------
48 
49 int ann_Ndata_pts = 0; // number of data points
50 int ann_Nvisit_lfs = 0; // number of leaf nodes visited
51 int ann_Nvisit_spl = 0; // number of splitting nodes visited
52 int ann_Nvisit_shr = 0; // number of shrinking nodes visited
53 int ann_Nvisit_pts = 0; // visited points for one query
54 int ann_Ncoord_hts = 0; // coordinate hits for one query
55 int ann_Nfloat_ops = 0; // floating ops for one query
56 ANNsampStat ann_visit_lfs; // stats on leaf nodes visits
57 ANNsampStat ann_visit_spl; // stats on splitting nodes visits
58 ANNsampStat ann_visit_shr; // stats on shrinking nodes visits
59 ANNsampStat ann_visit_nds; // stats on total nodes visits
60 ANNsampStat ann_visit_pts; // stats on points visited
61 ANNsampStat ann_coord_hts; // stats on coordinate hits
62 ANNsampStat ann_float_ops; // stats on floating ops
63 //
64 ANNsampStat ann_average_err; // average error
65 ANNsampStat ann_rank_err; // rank error
66 
67 //----------------------------------------------------------------------
68 // Routines for statistics.
69 //----------------------------------------------------------------------
70 
71 DLL_API void annResetStats(int data_size) // reset stats for a set of queries
72 {
83 }
84 
85 DLL_API void annResetCounts() // reset counts for one query
86 {
87  ann_Nvisit_lfs = 0;
88  ann_Nvisit_spl = 0;
89  ann_Nvisit_shr = 0;
90  ann_Nvisit_pts = 0;
91  ann_Ncoord_hts = 0;
92  ann_Nfloat_ops = 0;
93 }
94 
95 DLL_API void annUpdateStats() // update stats with current counts
96 {
104 }
105 
106  // print a single statistic
107 void print_one_stat(const char* title, ANNsampStat s, double div)
108 {
109  cout << title << "= [ ";
110  cout.width(9); cout << s.mean()/div << " : ";
111  cout.width(9); cout << s.stdDev()/div << " ]<";
112  cout.width(9); cout << s.min()/div << " , ";
113  cout.width(9); cout << s.max()/div << " >\n";
114 }
115 
116 DLL_API void annPrintStats( // print statistics for a run
117  ANNbool validate) // true if average errors desired
118 {
119  cout.precision(4); // set floating precision
120  cout << " (Performance stats: "
121  << " [ mean : stddev ]< min , max >\n";
122  print_one_stat(" leaf_nodes ", ann_visit_lfs, 1);
123  print_one_stat(" splitting_nodes ", ann_visit_spl, 1);
124  print_one_stat(" shrinking_nodes ", ann_visit_shr, 1);
125  print_one_stat(" total_nodes ", ann_visit_nds, 1);
126  print_one_stat(" points_visited ", ann_visit_pts, 1);
127  print_one_stat(" coord_hits/pt ", ann_coord_hts, ann_Ndata_pts);
128  print_one_stat(" floating_ops_(K) ", ann_float_ops, 1000);
129  if (validate) {
130  print_one_stat(" average_error ", ann_average_err, 1);
131  print_one_stat(" rank_error ", ann_rank_err, 1);
132  }
133  cout.precision(0); // restore the default
134  cout << " )\n";
135  cout.flush();
136 }
ANNsampStat ann_visit_nds
Definition: perf.cpp:59
DLL_API void annPrintStats(ANNbool validate)
Definition: perf.cpp:116
ANNbool
Definition: ANN.h:132
ANNsampStat ann_visit_spl
Definition: perf.cpp:57
DLL_API void annResetStats(int data_size)
Definition: perf.cpp:71
DLL_API ANNsampStat ann_average_err
Definition: perf.cpp:64
int ann_Ncoord_hts
Definition: perf.cpp:54
int ann_Nfloat_ops
Definition: perf.cpp:55
ANNbool validate
Definition: ann_test.cpp:489
double stdDev()
Definition: ANNperf.h:113
int data_size
Definition: ann_test.cpp:473
double max()
Definition: ANNperf.h:116
int ann_Nvisit_pts
Definition: perf.cpp:53
DLL_API void annUpdateStats()
Definition: perf.cpp:95
void print_one_stat(const char *title, ANNsampStat s, double div)
Definition: perf.cpp:107
int ann_Ndata_pts
Definition: perf.cpp:49
void reset()
Definition: ANNperf.h:91
ANNsampStat ann_visit_pts
Definition: perf.cpp:60
ANNsampStat ann_visit_lfs
Definition: perf.cpp:56
int ann_Nvisit_shr
Definition: perf.cpp:52
int ann_Nvisit_spl
Definition: perf.cpp:51
ANNsampStat ann_coord_hts
Definition: perf.cpp:61
double min()
Definition: ANNperf.h:115
ANNsampStat ann_float_ops
Definition: perf.cpp:62
int ann_Nvisit_lfs
Definition: perf.cpp:50
DLL_API ANNsampStat ann_rank_err
Definition: perf.cpp:65
ANNsampStat ann_visit_shr
Definition: perf.cpp:58
double mean()
Definition: ANNperf.h:110
DLL_API void annResetCounts()
Definition: perf.cpp:85
#define DLL_API
Definition: ANN.h:85

Generated on Thu Jun 11 2015 13:52:31 for queso-0.53.0 by  doxygen 1.8.5