Implemented Admin#profiling_info.

This commit is contained in:
Jim Menard 2009-01-07 15:58:54 -05:00
parent 17bbc83f5d
commit 60ab3d99dc
3 changed files with 18 additions and 0 deletions

View File

@ -66,6 +66,7 @@ module XGen
# Return an array contining current profiling information from the # Return an array contining current profiling information from the
# database. # database.
def profiling_info def profiling_info
@db.query(DB::SYSTEM_PROFILE_COLLECTION, Query.new({})).to_a
end end
# Validate a named collection. # Validate a named collection.

View File

@ -32,6 +32,7 @@ module XGen
SYSTEM_NAMESPACE_COLLECTION = "system.namespaces" SYSTEM_NAMESPACE_COLLECTION = "system.namespaces"
SYSTEM_INDEX_COLLECTION = "system.indexes" SYSTEM_INDEX_COLLECTION = "system.indexes"
SYSTEM_PROFILE_COLLECTION = "system.profile"
SYSTEM_COMMAND_COLLECTION = "$cmd" SYSTEM_COMMAND_COLLECTION = "$cmd"
# Strict mode enforces collection existence checks. When +true+, # Strict mode enforces collection existence checks. When +true+,

View File

@ -37,4 +37,20 @@ class AdminTest < Test::Unit::TestCase
assert_equal :off, @admin.profiling_level assert_equal :off, @admin.profiling_level
end end
def test_profiling_info
# Perform at least one query while profiling so we have something to see.
@admin.profiling_level = :all
@coll.find()
info = @admin.profiling_info
assert_kind_of Array, info
assert info.length >= 1
first = info.first
assert_kind_of String, first['info']
assert_kind_of Time, first['ts']
assert_kind_of Numeric, first['millis']
@admin.profiling_level = :off
end
end end