Skip to content

Commit c7750aa

Browse files
committed
chg: wrapped stats with #if DETAILED_STATS
1 parent bcd1c8c commit c7750aa

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/fsrc.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
int main( int argc, char* argv[] ) {
88

9+
#if DETAILED_STATS
910
StopWatch total;
1011
total.start();
12+
#endif
1113

1214
SearchOptions opts = SearchOptions::parseArgs( argc, argv );
1315

@@ -32,12 +34,11 @@ int main( int argc, char* argv[] ) {
3234
searcher.onAllFiles();
3335
}
3436

35-
auto ms = total.stop() / 1000000;
36-
3737
#if DETAILED_STATS
38+
auto ms = total.stop() / 1000000;
3839
searcher.printStats();
39-
#endif
4040
searcher.printFooter( ms );
41+
#endif
4142

4243
ExitQueue::call();
4344
return 0;

src/searchcontroller.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ void SearchController::onAllFiles() {
1313

1414
utils::recurseDir( opts.path.native(), [&pool, this]( const sys_string & filename ) {
1515
pool.add( [filename, this] {
16+
#if DETAILED_STATS
1617
stats.filesSearched++;
18+
#endif
1719
search( filename );
1820
} );
1921
} );
@@ -30,7 +32,9 @@ void SearchController::onGitFiles() {
3032

3133
utils::gitLsFiles( opts.path, [&pool, this]( const sys_string & filename ) {
3234
pool.add( [filename, this] {
35+
#if DETAILED_STATS
3336
stats.filesSearched++;
37+
#endif
3438
search( filename );
3539
} );
3640
} );
@@ -50,6 +54,7 @@ void SearchController::printGitHeader() {
5054
}
5155
}
5256

57+
#if DETAILED_STATS
5358
void SearchController::printStats() {
5459
if( !opts.piped ) {
5560
utils::printColor( gray, utils::format(
@@ -74,6 +79,7 @@ void SearchController::printFooter( const StopWatch::ns_type& ms ) {
7479
ms ) );
7580
}
7681
}
82+
#endif
7783

7884
void SearchController::search( const sys_string& path ) {
7985

@@ -87,7 +93,9 @@ void SearchController::search( const sys_string& path ) {
8793
utils::FileView view = utils::fromWinAPI( path );
8894
#endif
8995

96+
#if DETAILED_STATS
9097
stats.bytesRead += view.size;
98+
#endif
9199
STOP( stats.t_read )
92100

93101
if( !view.size ) { return; }
@@ -103,8 +111,10 @@ void SearchController::search( const sys_string& path ) {
103111

104112
// handle matches
105113
if( !matches.empty() ) {
114+
#if DETAILED_STATS
106115
stats.filesMatched++;
107116
stats.matches += matches.size();
117+
#endif
108118

109119
START
110120
static thread_local std::unique_ptr<Printer> printer( makePrinter() );

src/searchcontroller.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ struct SearchController {
3030
SearchOptions opts;
3131
std::function<Searcher*()> makeSearcher;
3232
std::function<Printer*()> makePrinter;
33+
#if DETAILED_STATS
3334
Stats stats;
35+
#endif
3436
Color gray = Color::Gray;
3537

3638
SearchController( const SearchOptions& opts, std::function<Searcher*()> searcher, std::function<Printer*()> printer ):

0 commit comments

Comments
 (0)