3
/* Copyright 2012 10gen Inc.
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
20
#include "mongo/db/jsobj.h"
21
#include "mongo/util/concurrency/spin_lock.h"
22
#include "mongo/util/timer.h"
28
* Holds timing information in milliseconds
29
* keeps track of number of times and total milliseconds
30
* so a diff can be computed
34
void recordMillis( int millis );
37
* @return number of millis
39
int record( const Timer& timer );
41
BSONObj getReport() const;
42
operator BSONObj() const { return getReport(); }
45
mutable SpinLock _lock;
47
long long _totalMillis;
51
* Holds an instance of a Timer such that we the time is recorded
52
* when the TimerHolder goes out of scope
56
/** Destructor will record to TimerStats */
57
TimerHolder( TimerStats* stats );
58
/** Will record stats if recordMillis hasn't (based on _recorded) */
62
* returns elapsed millis from internal timer
64
int millis() const { return _t.millis(); }
67
* records the time in the TimerStats and marks that we've
68
* already recorded so the destructor doesn't