当前位置: 首页>>代码示例>>C++>>正文


C++ DTime::totalSecs方法代码示例

本文整理汇总了C++中DTime::totalSecs方法的典型用法代码示例。如果您正苦于以下问题:C++ DTime::totalSecs方法的具体用法?C++ DTime::totalSecs怎么用?C++ DTime::totalSecs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DTime的用法示例。


在下文中一共展示了DTime::totalSecs方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testFind

		void testFind(int port, int top = 10000000) {
			DjondbConnection* conn = DjondbConnectionManager::getConnection("localhost", port);

			if (!conn->open()) {
				cout << "Not connected" << endl;
				exit(0);
			}

			Logger* log = getLogger(NULL);

			log->startTimeRecord();
			log->info("Testing find performance over: %d finds.", top);
			for (int x = 0; x < top; x++) {
				BSONArrayObj* arr = conn->executeQuery("select top 1 * from db:testperformance");
				if (arr->length() == 0) {
					log->info("Error an id was not found");
					exit(1);
				}
				delete arr;
			}
			log->stopTimeRecord();

			DTime time = log->recordedTime();

			cout << "Total find secs: " << time.totalSecs() << endl;
			if (time.totalSecs() > 0) {
				log->info("Found %d: throughtput: %d.", top, (top / time.totalSecs()));
			} else {
				log->info("Found :%d, throughtput too high to be measured", top);
			}
			if ((time.totalSecs() > 0) && ((top / time.totalSecs()) < 16000))  {
				log->info("Performance is not good enough");
			}
		}
开发者ID:FikiHafana,项目名称:djondb,代码行数:34,代码来源:testperformance.cpp

示例2: producer

void* producer(void* arg) {
	NetworkOutputStream* nos = new NetworkOutputStream();
	int socket = nos->open("localhost", _port);

	printf("Producer started\n");
	Logger* log = getLogger(NULL);
	log->info("Producer starter");
	log->startTimeRecord();
	if (socket > 0) {
		NetworkInputStream* nis = new NetworkInputStream(socket);

		std::auto_ptr<CommandWriter> writer(new CommandWriter(nos));

		for (int x = 0; x < MAX_INSERT; x++) {
			std::auto_ptr<InsertCommand> cmd(new InsertCommand());

			BSONObj* obj = new BSONObj();
			std::auto_ptr<std::string> guid(uuid());
			obj->add("_id", guid->c_str());
			char* temp = (char*)malloc(2000);
			memset(temp, 0, 2000);
			memset(temp, 'a', 1999);
			int len = strlen(temp);
			obj->add("content", temp);
			free(temp);
			cmd->setBSON(obj);
			std::string db("mydb");
			cmd->setDB(db);
			std::string ns("myns");
			cmd->setNameSpace(ns);
			cmd->setOptions(new BSONObj());
			writer->writeCommand(cmd.get());

			int result = nis->readInt();

			EXPECT_EQ(result, 1);
			if (result != 1) {
				break;
			}
		}
		nis->close();
	} else {
		printf("Socket is 0");
	}
	log->info("Producer end");
	log->stopTimeRecord();

	DTime time = log->recordedTime();
	if (time.totalSecs() > 0) {
		log->info("Producer time: %d secs. Operations per sec: %d", time.totalSecs(), MAX_INSERT / time.totalSecs());
	} else {
		EXPECT_TRUE(false) << "Something was wrong network could not execute " << MAX_INSERT << " in 0 secs.";
	}
}
开发者ID:FikiHafana,项目名称:djondb,代码行数:54,代码来源:main.cpp

示例3: testCommand

		void testCommand(int port, int top = 10000000) {
			DjondbConnection* conn = DjondbConnectionManager::getConnection("localhost", port);

			if (!conn->open()) {
				cout << "Not connected" << endl;
				exit(0);
			}

			Logger* log = getLogger(NULL);

			log->startTimeRecord();
			log->info("Testing command performance over: %d executions.", top);
			for (int x = 0; x < top; x++) {
				std::vector<std::string>* dbs = conn->dbs();
				if (dbs == NULL) {
					log->info("Test command failed and returned NULL");
					exit(1);
				}
				if (dbs->size() == 0) {
					log->info("Test command failed and returned 0 elements");
					exit(1);
				}
				delete dbs;
			}
			log->stopTimeRecord();

			DTime time = log->recordedTime();

			cout << "Total secs: " << time.totalSecs() << endl;
			if (time.totalSecs() > 0) {
				log->info("Executed %d: throughtput: %d.", top, (top / time.totalSecs()));
			} else {
				log->info("Executed %d, throughtput too high to be measured", top);
			}
			if ((time.totalSecs() > 0) && ((top / time.totalSecs()) < 5000))  {
				log->info("Performance is not good enough");
			}
		}
开发者ID:FikiHafana,项目名称:djondb,代码行数:38,代码来源:testperformance.cpp

示例4: getLogger

TEST(testUtil, testLogger) {
	// Test timer
	//
	Logger* log = getLogger(NULL);
	log->startTimeRecord();
	Thread::sleep(3000);
	log->stopTimeRecord();

	DTime time = log->recordedTime();

	long secs = time.totalSecs();

	EXPECT_TRUE(secs > 2);
	EXPECT_TRUE(secs < 4);
}
开发者ID:FikiHafana,项目名称:djondb,代码行数:15,代码来源:main.cpp

示例5: testPerfomance

		void testPerfomance(int port, int top = 10000000) {
			DjondbConnection* conn = DjondbConnectionManager::getConnection("localhost", port);

			if (!conn->open()) {
				cout << "Not connected" << endl;
				exit(0);
			}

			// 1k inserts
			//
			Logger* log = getLogger(NULL);

			log->info("Testing performance over: %d inserts.", top);
			std::vector<std::string>* names = generateNames(top);
			std::vector<std::string*>* ids = new std::vector<std::string*>();
			log->startTimeRecord();
			for (int x = 0; x < top; x++) {
				BSONObj obj;
				char* text = (char*)malloc(1001);
				memset(text, 0, 1001);
				memset(text, 'a', 1000);

				std::string* id = uuid();
				obj.add("_id", id->c_str());
				int test = rand() % 100;
				if (test > 30) {
					ids->push_back(id);
				} else {
					delete id;
				}
				obj.add("t", x);

				obj.add("text", text);
				obj.add("name", const_cast<char*>(names->at(x).c_str()));

				conn->insert("db", "testperformance", obj);
				free(text);
				// every 10 % will print a message showing the progress
				if ((x % (top / 10)) == 0) {
					DTime timeTemp = log->recordedTime();
					int progress = (x * 100) / top;
					if (timeTemp.totalSecs() > 0) {
						log->info("Inserted %d: throughtput: %d per sec. %d comnpleted", x, (x / timeTemp.totalSecs()), progress);
					} else {
						log->info("Inserted :%d, throughtput too high to be measured. %d completed.", x, progress);
					}
				}
			}

			log->stopTimeRecord();

			DTime time = log->recordedTime();

			cout << "Total secs: " << time.totalSecs() << endl;
			if (time.totalSecs() > 0) {
				log->info("Inserted %d: throughtput: %d.", top, (top / time.totalSecs()));
			} else {
				log->info("Inserted %d, throughtput too high to be measured", top);
			}
			if ((time.totalSecs() > 0) && ((top / time.totalSecs()) < 16000))  {
				log->info("Performance is not good enough");
			}


			conn->close();

			delete log;
		}
开发者ID:FikiHafana,项目名称:djondb,代码行数:68,代码来源:testperformance.cpp


注:本文中的DTime::totalSecs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。