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


C++ CDateTime::AddMinutes方法代码示例

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


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

示例1: runTest

// RunTest
void CDriver::runTest(int iSleep, int iTestDuration)
{
	g_tid = (pthread_t*) malloc(sizeof(pthread_t) * iUsers);

	// before starting the test run Trade-Cleanup transaction
	cout << endl <<
			"Running Trade-Cleanup transaction before starting the test..." <<
			endl;
	m_pCDM->DoCleanupTxn();
	cout << "Trade-Cleanup transaction completed." << endl << endl;

	// time to sleep between thread creation, convert from millaseconds to
	// nanoseconds.
	struct timespec ts, rem;
	ts.tv_sec = (time_t) (iSleep / 1000);
	ts.tv_nsec = (long) (iSleep % 1000) * 1000000;

	// Caulculate when the test should stop.
	int threads_start_time =
			(int) ((double) iSleep / 1000.0 * (double) iUsers);
	stop_time = time(NULL) + iTestDuration + threads_start_time;

	CDateTime dtAux;
	dtAux.SetToCurrent();

	cout << "Test is starting at " << dtAux.ToStr(02) << endl <<
			"Estimated duration of ramp-up: " << threads_start_time <<
			" seconds" << endl;

	dtAux.AddMinutes((iTestDuration + threads_start_time)/60);
	cout << "Estimated end time " << dtAux.ToStr(02) << endl;

	logErrorMessage(">> Start of ramp-up.\n");

	// start thread that runs the Data Maintenance transaction
	entryDMWorkerThread(this);

	// parameter for the new thread
	PCustomerThreadParam pThrParam;

	for (int i = 1; i <= iUsers; i++) {
		pThrParam = new TCustomerThreadParam;
		// zero the structure
		memset(pThrParam, 0, sizeof(TCustomerThreadParam));
		pThrParam->pDriver = this;

		entryCustomerWorkerThread(reinterpret_cast<void *>(pThrParam), i);

		// Sleep for between starting terminals
		while (nanosleep(&ts, &rem) == -1) {
			if (errno == EINTR) {
				memcpy(&ts, &rem, sizeof(timespec));
			} else {
				ostringstream osErr;
				osErr << "sleep time invalid " << ts.tv_sec << " s " <<
						ts.tv_nsec << " ns" << endl;
				logErrorMessage(osErr.str());
				break;
			}
		}
	}

	// mark end of ramp-up
	m_MixLock.lock();
	m_fMix << (int) time(NULL) << ",START,,," <<
			(long long) pthread_self() << endl;
	m_MixLock.unlock();

	logErrorMessage(">> End of ramp-up.\n\n");

	// wait until all threads quit
	// 0 represents the Data-Maintenance thread
	for (int i = 0; i <= iUsers; i++) {
		if (pthread_join(g_tid[i], NULL) != 0) {
			throw new CThreadErr( CThreadErr::ERR_THREAD_JOIN,
					"Driver::RunTest" );
		}
	}
}
开发者ID:mw2q,项目名称:dbt5,代码行数:80,代码来源:Driver.cpp


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