summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dbtests/perftests.cpp66
-rw-r--r--util/mmap.h2
-rw-r--r--util/version.cpp1
3 files changed, 64 insertions, 5 deletions
diff --git a/dbtests/perftests.cpp b/dbtests/perftests.cpp
index 7fb634c236d..187c1eb1cc2 100644
--- a/dbtests/perftests.cpp
+++ b/dbtests/perftests.cpp
@@ -34,6 +34,9 @@
#include "dbtests.h"
#include "../db/dur_stats.h"
#include "../util/checksum.h"
+#include "../util/version.h"
+
+using namespace bson;
namespace PerfTests {
typedef DBDirectClient DBClientType;
@@ -119,12 +122,65 @@ namespace PerfTests {
/* override if your test output doesn't need that */
virtual bool showDurStats() { return true; }
+ static DBClientConnection *conn;
+
public:
void say(unsigned long long n, int ms, string s) {
- cout << "stats " << setw(33) << left << s << ' ' << setw(8) << /*rps*/n*1000/ms << ' ' << right << setw(6) << ms << "ms ";
- if( showDurStats() )
- cout << dur::stats.curr->_asCSV();
- cout << endl;
+ unsigned long long rps = n*1000/ms;
+ cout << "stats " << setw(33) << left << s << ' ' << setw(8) << rps << ' ' << right << setw(6) << ms << "ms ";
+ if( showDurStats() )
+ cout << dur::stats.curr->_asCSV();
+ cout << endl;
+
+ /* if you want recording of the timings, place the password for the perf database
+ in a "pstats.login" text file in the current directory for the test binary
+ */
+ if( exists("pstats.login") ) {
+ try {
+ if( conn == 0 ) {
+ MemoryMappedFile f;
+ void *p = f.mapWithOptions("pstats.login", MongoFile::READONLY);
+ string pwd((const char *)p, (unsigned) f.length());
+ conn = new DBClientConnection(false, 0, 10);
+ string err;
+ if( conn->connect("mongo05.10gen.cust.cbici.net", err) ) {
+ if( !conn->auth("perf", "perf", pwd, err) ) {
+ cout << "info: authentication with stats before logging failed: " << err << endl;
+ assert(false);
+ }
+ }
+ else {
+ cout << err << " (to log pstats)" << endl;
+ }
+ }
+ if( conn && !conn->isFailed() ) {
+ bob b;
+ b.append("host", getHostName());
+ b.appendTimeT("when", time(0));
+ b.append("test", s);
+ b.append("rps", (int) rps);
+ b.append("millis", ms);
+ b.appendBool("dur", cmdLine.dur);
+ if( showDurStats() && cmdLine.dur )
+ b.append("durStats", dur::stats.curr->_asObj());
+ {
+ bob inf;
+ inf.append("version", versionString);
+ if( sizeof(int*) == 4 ) inf.append("bits", 32);
+ #if defined(_WIN32)
+ inf.append("os", "win");
+ #endif
+ inf.append("git", gitVersion());
+ inf.append("boost", BOOST_VERSION);
+ b.append("info", inf.obj());
+ }
+
+ conn->insert("perf.pstats", b.obj());
+ }
+ }
+ catch(...) {
+ }
+ }
}
void run() {
_ns = string("perftest.") + name();
@@ -188,6 +244,8 @@ namespace PerfTests {
}
};
+ DBClientConnection *B::conn;
+
unsigned dontOptimizeOutHopefully;
// test thread local speed
diff --git a/util/mmap.h b/util/mmap.h
index cded98cdbb0..23c9f0c456d 100644
--- a/util/mmap.h
+++ b/util/mmap.h
@@ -154,6 +154,8 @@ namespace mongo {
// Throws exception if file doesn't exist. (dm may2010: not sure if this is always true?)
void* map(const char *filename);
+
+ /** @param options see MongoFile::Options */
void* mapWithOptions(const char *filename, int options);
/* Creates with length if DNE, otherwise uses existing file length,
diff --git a/util/version.cpp b/util/version.cpp
index 80f086e25d9..acbf1da3b42 100644
--- a/util/version.cpp
+++ b/util/version.cpp
@@ -36,7 +36,6 @@ namespace mongo {
*/
const char versionString[] = "1.9.0-pre-";
-
// See unit test for example outputs
static BSONArray _versionArray(const char* version){
// this is inefficient, but cached so it doesn't matter