Skip to content

Commit

Permalink
bench support for (create|drop)Index
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Oct 16, 2011
1 parent 795c702 commit 9c6d24a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions jstests/bench_test1.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,12 @@ seconds = .7

res = benchRun( { ops : ops , parallel : 2 , seconds : seconds , host : db.getMongo().host } )
assert.lte( seconds * res.update , t.findOne( { _id : 1 } ).x , "A1" )


assert.eq( 1 , t.getIndexes().length , "B1" )
benchRun( { ops : [ { op : "createIndex" , ns : t.getFullName() , key : { x : 1 } } ] , parallel : 1 , seconds : 1 , host : db.getMongo().host } )
assert.eq( 2 , t.getIndexes().length , "B2" )
benchRun( { ops : [ { op : "dropIndex" , ns : t.getFullName() , key : { x : 1 } } ] , parallel : 1 , seconds : 1 , host : db.getMongo().host } )
assert.eq( 1 , t.getIndexes().length , "B3" )


6 changes: 6 additions & 0 deletions scripting/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ namespace mongo {
result["code"].eoo() ? 0 : result["code"].Int() );
}
}
else if ( op == "createIndex" ) {
conn->ensureIndex( ns , e["key"].Obj() , false , "" , false );
}
else if ( op == "dropIndex" ) {
conn->dropIndex( ns , e["key"].Obj() );
}
else {
log() << "don't understand op: " << op << endl;
config->error = true;
Expand Down

0 comments on commit 9c6d24a

Please sign in to comment.