diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-12-25 02:04:19 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-12-25 02:04:19 -0500 |
commit | 5d7fd2df7bf55ff4cbe3bf7b79d764dbc4ddba2f (patch) | |
tree | d2fba6082d16c1374c58c56463e13a97bf4980ef /dbtests | |
parent | de3564331d6bc9e8bc79b1b45880df44f73e7cc9 (diff) | |
download | mongo-5d7fd2df7bf55ff4cbe3bf7b79d764dbc4ddba2f.tar.gz |
some Matcher speed test harnessing
Diffstat (limited to 'dbtests')
-rw-r--r-- | dbtests/matchertests.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/dbtests/matchertests.cpp b/dbtests/matchertests.cpp index 696c924e1aa..e418343712b 100644 --- a/dbtests/matchertests.cpp +++ b/dbtests/matchertests.cpp @@ -18,12 +18,15 @@ */ #include "pch.h" -#include "../db/matcher.h" +#include "../util/timer.h" +#include "../db/matcher.h" #include "../db/json.h" #include "dbtests.h" + + namespace MatcherTests { class Basic { @@ -116,6 +119,28 @@ namespace MatcherTests { } }; + + class TimingBase { + public: + long time( const BSONObj& patt , const BSONObj& obj ){ + Matcher m( patt ); + Timer t; + for ( int i=0; i<10000; i++ ){ + ASSERT( m.matches( obj ) ); + } + return t.millis(); + } + }; + + class AllTiming : public TimingBase { + public: + void run(){ + long normal = time( BSON( "x" << 5 ) , BSON( "x" << 5 ) ); + long all = time( BSON( "x" << BSON( "$all" << BSON_ARRAY( 5 ) ) ) , BSON( "x" << 5 ) ); + + cout << "normal: " << normal << " all: " << all << endl; + } + }; class All : public Suite { public: @@ -130,6 +155,7 @@ namespace MatcherTests { add< MixedNumericIN >(); add< Size >(); add< MixedNumericEmbedded >(); + add< AllTiming >(); } } dball; |