0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

dur towards stats

This commit is contained in:
dwight 2010-12-26 11:07:06 -05:00
parent 4260a74dbd
commit f35b33da44
3 changed files with 24 additions and 6 deletions

View File

@ -73,10 +73,19 @@ namespace mongo {
Stats stats;
Stats::Stats() {
void Stats::S::reset() {
memset(this, 0, sizeof(*this));
}
BSONObj Stats::S::asObj() {
return BSON(
"commits" << _commits <<
"journaledMB" << _journaledBytes / 1000000.0 <<
"writeToDataFileMB" << _writeToDataFilesBytes / 1000000.0 <<
"commitsInWriteLock" << _commitsInWriteLock
);
}
DurableInterface* DurableInterface::_impl = new NonDurableImpl();
void NonDurableImpl::startup() {
@ -265,7 +274,7 @@ namespace mongo {
std::stringstream ss;
ss << "dur error warning views mismatch " << mmf->filename() << ' ' << (hex) << low << ".." << high << " len:" << high-low+1;
log() << ss.str() << endl;
log() << "priv loc: " << (void*)(p+low) << ' ' << stats.curr._objCopies << endl;
log() << "priv loc: " << (void*)(p+low) << ' ' << endl;
set<WriteIntent>& b = commitJob.writes();
(void)b; // mark as unused. Useful for inspection in debugger

View File

@ -7,10 +7,12 @@ namespace mongo {
uncommon (from a serverStatus command and such). Thus, there should not be multicore chatter overhead.
*/
struct Stats {
Stats();
Stats() { curr.reset(); }
struct S {
BSONObj asObj();
void reset();
unsigned _commits;
unsigned _objCopies;
unsigned long long _journaledBytes;
unsigned long long _writeToDataFilesBytes;

View File

@ -32,6 +32,7 @@
#include "../db/taskqueue.h"
#include "../util/timer.h"
#include "dbtests.h"
#include "../db/dur_stats.h"
namespace PerfTests {
typedef DBDirectClient DBClientType;
@ -111,12 +112,17 @@ namespace PerfTests {
virtual string name() = 0;
virtual unsigned long long expectation() = 0;
public:
void say(unsigned long long n, int ms, string s) {
cout << setw(36) << left << s << ' ' << right << setw(7) << n*1000/ms << "/sec " << setw(4) << ms << "ms" << endl;
cout << dur::stats.curr.asObj().toString() << endl;
}
void run() {
_ns = string("perftest.") + name();
client().dropCollection(ns());
prep();
dur::stats.curr.reset();
Timer t;
unsigned long long n = 0;
const unsigned Batch = 50;
@ -128,7 +134,7 @@ namespace PerfTests {
} while( t.millis() < 5000 );
client().getLastError(); // block until all ops are finished
int ms = t.millis();
cout << setw(36) << name() << ' ' << setw(7) << n*1000/ms << "/sec " << setw(4) << ms << "ms" << endl;
say(n, ms, name());
if( n < expectation() ) {
cout << "test " << name() << " seems slow n:" << n << " ops/sec but expect greater than:" << expectation() << endl;
@ -140,6 +146,7 @@ namespace PerfTests {
{
const char *test2name = timed2();
if( test2name ) {
dur::stats.curr.reset();
Timer t;
unsigned long long n = 0;
while( 1 ) {
@ -151,7 +158,7 @@ namespace PerfTests {
break;
}
int ms = t.millis();
cout << setw(36) << test2name << ' ' << setw(7) << n << "/sec " << setw(4) << ms << "ms" << endl;
say(n, ms, test2name);
}
}
}