0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

use static variables for OCCASIONALLY/RARELY/ONCE to get per function uniqueness

This commit is contained in:
Aaron 2009-04-27 19:12:32 -04:00
parent ed8bf45202
commit cc3887c864
6 changed files with 13 additions and 13 deletions

View File

@ -90,8 +90,8 @@ namespace mongo {
int m = t.millis();
if ( m > 100 ) {
out() << "dbeval slow, time: " << dec << m << "ms " << ns << endl;
OCCASIONALLY log() << code << endl;
else if ( m >= 1000 ) log() << code << endl;
if ( m >= 1000 ) log() << code << endl;
else OCCASIONALLY log() << code << endl;
}
}
if ( res ) {

View File

@ -94,6 +94,7 @@ int main( int argc, char** argv ) {
// make sure all tests run with this setup, by running javajs tests first.
tests.add( jsTests(), "js" );
tests.add( basicTests(), "basic" );
tests.add( btreeTests(), "btree" );
tests.add( jsobjTests(), "jsobj" );
tests.add( jsonTests(), "json" );

View File

@ -21,6 +21,7 @@
using namespace mongo;
UnitTest::TestPtr basicTests();
UnitTest::TestPtr btreeTests();
UnitTest::TestPtr jsTests();
UnitTest::TestPtr jsobjTests();

View File

@ -249,6 +249,7 @@
93B4A81B0F1C01D8000C862C /* lasterror.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lasterror.cpp; sourceTree = "<group>"; };
93B4A8290F1C024C000C862C /* cursor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cursor.cpp; sourceTree = "<group>"; };
93B4A82A0F1C0256000C862C /* pdfiletests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pdfiletests.cpp; sourceTree = "<group>"; };
93C38E940FA66622007D6E4A /* basictests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = basictests.cpp; sourceTree = "<group>"; };
93CCC87F0F8562E900E20FA0 /* datasize.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = datasize.js; sourceTree = "<group>"; };
93D0C1520EF1D377005253B7 /* jsobjtests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsobjtests.cpp; sourceTree = "<group>"; };
93D0C1FB0EF1E267005253B7 /* namespacetests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = namespacetests.cpp; sourceTree = "<group>"; };
@ -369,6 +370,7 @@
934223850EF16D7000608550 /* dbtests */ = {
isa = PBXGroup;
children = (
93C38E940FA66622007D6E4A /* basictests.cpp */,
93AB914E0F4F1C7A0020A046 /* javajstests.cpp */,
932AC3EB0F4A5B34005BF8B0 /* queryoptimizertests.cpp */,
933E22100F4327B2000209E3 /* perf */,

View File

@ -299,14 +299,13 @@ namespace mongo {
#define DEBUGGING if( 0 )
extern unsigned occasion;
extern unsigned occasionR;
extern unsigned once;
#define OCCASIONALLY if( ++occasion % 16 == 0 )
#define RARELY if( ++occasionR % 128 == 0 )
#define ONCE if( ++once == 1 )
// The following declare one unique counter per enclosing function.
// NOTE The implementation double-increments on a match, but we don't really care.
#define SOMETIMES( occasion, howOften ) for( static unsigned occasion = 0; ++occasion % howOften == 0; )
#define OCCASIONALLY SOMETIMES( occasionally, 16 )
#define RARELY SOMETIMES( rarely, 128 )
#define ONCE for( static bool undone = true; undone; undone = false )
#if defined(_WIN32)
#define strcasecmp _stricmp
inline void our_debug_free(void *p) {

View File

@ -33,9 +33,6 @@ namespace mongo {
int logLevel = 0;
boost::mutex Logstream::mutex;
unsigned occasion = 0;
unsigned occasionR = 0;
unsigned once = 0;
bool goingAway = false;
bool isPrime(int n) {