summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
Diffstat (limited to 'jstests')
-rw-r--r--jstests/profile1.js30
1 files changed, 16 insertions, 14 deletions
diff --git a/jstests/profile1.js b/jstests/profile1.js
index 9654357127f..ba01d597c39 100644
--- a/jstests/profile1.js
+++ b/jstests/profile1.js
@@ -55,12 +55,18 @@ try {
db.eval("sleep(1)") // pre-load system.js
- db.setProfilingLevel(2);
- before = db.system.profile.count();
+ function resetProfile( level , slowms ) {
+ db.setProfilingLevel(0);
+ db.system.profile.drop();
+ db.setProfilingLevel(level,slowms);
+ }
+
+ resetProfile(2);
+
db.eval( "sleep(25)" )
db.eval( "sleep(120)" )
- after = db.system.profile.count()
- assert.eq( before + 3 , after , "X1" )
+
+ assert.eq( 2 , db.system.profile.find( { "command.$eval" : /^sleep/ } ).count() );
/* sleep() could be inaccurate on certain platforms. let's check */
print("\nsleep 2 time actual:");
@@ -90,24 +96,20 @@ try {
return actual >= max ? 1 : 0;
}
- db.setProfilingLevel(1,100);
- before = db.system.profile.count();
+ resetProfile(1,100);
var delta = 0;
delta += evalSleepMoreThan( 15 , 100 );
delta += evalSleepMoreThan( 120 , 100 );
- after = db.system.profile.count()
- assert.eq( before + delta , after , "X2 : " + getProfileAString() )
+ assert.eq( delta , db.system.profile.find( { "command.$eval" : /^sleep/ } ).count() , "X2 : " + getProfileAString() )
- db.setProfilingLevel(1,20);
- before = db.system.profile.count();
+ resetProfile(1,20);
delta = 0;
delta += evalSleepMoreThan( 5 , 20 );
delta += evalSleepMoreThan( 120 , 20 );
- after = db.system.profile.count()
- assert.eq( before + delta , after , "X3 : " + getProfileAString() )
+ assert.eq( delta , db.system.profile.find( { "command.$eval" : /^sleep/ } ).count() , "X3 : " + getProfileAString() )
- db.profile.drop();
- db.setProfilingLevel(2)
+ resetProfile(2);
+ db.profile1.drop();
var q = { _id : 5 };
var u = { $inc : { x : 1 } };
db.profile1.update( q , u );