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


C++ SimpleTimer::Start方法代码示例

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


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

示例1: main

int main()
{
    SimpleTimer timer;

    cout << "Begin timer!" << endl;
    timer.Start();

    sleep( 2 );

    cout << "Elapsed time: " << timer.GetElapsed() << endl;

    return 0;
}
开发者ID:Rachels-Courses,项目名称:CPP-Course,代码行数:13,代码来源:main.cpp

示例2: doTest

void doTest(const int numThreads, std::thread* threads, const bool stest, const bool locking)
{
	iterations = 1;
	do
	{
		SimpleTimer timer;
		timer.Start();
		//initialize testing threads, then wait for all threads to finish
		if(stest)
		{
			for(int i = 0; i < numThreads; ++i)
			{
				threads[i] = std::thread(StackSThread);
			}
		}
		else 
		{
			for(int i = 0; i < numThreads; ++i)
			{
				threads[i] = std::thread(StackTThread);
			}
		}
		for(int i = 0; i < numThreads; ++i)
		{
			threads[i].join();
		}
		timer.Stop();
		while(!stack->IsEmpty())
		{
			delete (stack->Pop());
		}
		std::cout << (locking ? "Locking " : "LockFree ") << (stest ? "STest " : "TTest ") <<
		    iterations << " inner iterations with " <<
			numThreads << " threads: " << timer.ElapsedMilliseconds() << std::endl;

		std::ofstream outfile;
		outfile.open(OUTPUT_FILE, std::ios_base::app);
		outfile << (locking ? "L," : "F,") << (stest ? "S," : "T,") << iterations << "," << numThreads << "," << timer.ElapsedMilliseconds() << std::endl;
		outfile.close();

		iterations = iterations << 1;
	}
	while(iterations < MAX_INNER_ITERATIONS);
}
开发者ID:rworr,项目名称:LockFree,代码行数:44,代码来源:StackTest.hpp

示例3: doParallelSuperPMI

int doParallelSuperPMI(CommandLine::Options& o)
{
    HRESULT hr = E_FAIL;
    SimpleTimer st;
    st.Start();

#ifndef FEATURE_PAL // TODO-Porting: handle Ctrl-C signals gracefully on Unix
    //Register a ConsoleCtrlHandler
    if (!SetConsoleCtrlHandler(CtrlHandler, TRUE))
    {
        LogError("Failed to set control handler.");
        return 1;
    }
#endif // !FEATURE_PAL

    char tempPath[MAX_PATH];
    if (!GetTempPath(MAX_PATH, tempPath))
    {
        LogError("Failed to get path to temp folder.");
        return 1;
    }

    if (o.workerCount <= 0)
    {
        //Use the default value which is the number of processors on the machine.
        SYSTEM_INFO sysinfo;
        GetSystemInfo(&sysinfo);

        o.workerCount = sysinfo.dwNumberOfProcessors;

        //If we ever execute on a machine which has more than MAXIMUM_WAIT_OBJECTS(64) CPU cores
        //we still can't spawn more than the max supported by WaitForMultipleObjects()
        if (o.workerCount > MAXIMUM_WAIT_OBJECTS)
            o.workerCount = MAXIMUM_WAIT_OBJECTS;
    }

    // Obtain the folder path of the current executable, which we will use to spawn ourself.
    char* spmiFilename = new char[MAX_PATH];
    if (!GetModuleFileName(NULL, spmiFilename, MAX_PATH))
    {
        LogError("Failed to get current exe path.");
        return 1;
    }

    char* spmiArgs = ConstructChildProcessArgs(o);

    // TODO: merge all this output to a single call to LogVerbose to avoid all the newlines.
    LogVerbose("Using child (%s) with args (%s)", spmiFilename, spmiArgs);
    if (o.mclFilename != nullptr)
        LogVerbose(" failingMCList=%s", o.mclFilename);
    if (o.diffMCLFilename != nullptr)
        LogVerbose(" diffMCLFilename=%s", o.diffMCLFilename);
    LogVerbose(" workerCount=%d, skipCleanup=%d.", o.workerCount, o.skipCleanup);

    HANDLE *hProcesses = new HANDLE[o.workerCount];
    HANDLE *hStdOutput = new HANDLE[o.workerCount];
    HANDLE *hStdError  = new HANDLE[o.workerCount];

    char** arrFailingMCListPath = new char*[o.workerCount];
    char** arrDiffMCListPath    = new char*[o.workerCount];
    char** arrStdOutputPath     = new char*[o.workerCount];
    char** arrStdErrorPath      = new char*[o.workerCount];

    // Add a random number to the temporary file names to allow multiple parallel SuperPMI to happen at once.
    unsigned int randNumber = 0;
#ifdef FEATURE_PAL
    PAL_Random(/* bStrong */ FALSE, &randNumber, sizeof(randNumber));
#else // !FEATURE_PAL
    rand_s(&randNumber);
#endif // !FEATURE_PAL

    for (int i = 0; i < o.workerCount; i++)
    {
        if (o.mclFilename != nullptr)
        {
            arrFailingMCListPath[i] = new char[MAX_PATH];
            sprintf_s(arrFailingMCListPath[i], MAX_PATH, "%sParallelSuperPMI-%u-%d.mcl", tempPath, randNumber, i);
        }
        else
        {
            arrFailingMCListPath[i] = nullptr;
        }

        if (o.diffMCLFilename != nullptr)
        {
            arrDiffMCListPath[i] = new char[MAX_PATH];
            sprintf_s(arrDiffMCListPath[i], MAX_PATH, "%sParallelSuperPMI-Diff-%u-%d.mcl", tempPath, randNumber, i);
        }
        else
        {
            arrDiffMCListPath[i] = nullptr;
        }

        arrStdOutputPath[i] = new char[MAX_PATH];
        arrStdErrorPath[i]  = new char[MAX_PATH];

        sprintf_s(arrStdOutputPath[i], MAX_PATH, "%sParallelSuperPMI-stdout-%u-%d.txt", tempPath, randNumber, i);
        sprintf_s(arrStdErrorPath[i],  MAX_PATH, "%sParallelSuperPMI-stderr-%u-%d.txt", tempPath, randNumber, i);
    }

//.........这里部分代码省略.........
开发者ID:bretambrose,项目名称:coreclr,代码行数:101,代码来源:parallelsuperpmi.cpp

示例4: main

int main()
{
	//lex();
	//ConvertShit("../asBindings/LegacyBindings.cpp");
	//return 0;

	InitScriptEngine();

	const char* filename = "../Scripts/TestObjects.h"; //"../Scripts/TestSyntax.h"; //"../Scripts/Test1.cs";
	bool r = LoadAndBuildScriptFile(filename);

	//////////////////////////////////////////////////////////////////////////
	//Todo: All the script messin' goes here.
	//////////////////////////////////////////////////////////////////////////

	if(r)
	{

		ScriptClassThunk thunk = {};
		foo(thunk);

		SimpleTimer timer;

		const int NUM_SCRIPTS = 1;
		Script script[NUM_SCRIPTS] = {};

		for(u32 i(0); i != NUM_SCRIPTS; ++i)
		{
			if(!script[i].Init(&thunk))
				Printf("-----------Init failed!------------");
		}

		int frames=0;
		int nd=0;
		timer.Start();

		CallGlobalCallbackFunction(0);
		CallGlobalCallbackFunction(1);

		while(nd < NUM_SCRIPTS)
		{
			for(u32 i(0); i != NUM_SCRIPTS; ++i)
			{
				if(script[i].OnUpdate() == asEXECUTION_EXCEPTION)
				{
					script[i].OnDestroy();
					nd++; //destroy object?
				}
			}

			frames++;
		}

		SMinuteSecondsInfo msi = timer.GetElapsedTime();
		Printf("Elapsed time: %i minutes, %.2f seconds.\n",
			msi.minutes,
			msi.seconds
			);

		Printf("frames: %i, %.5f.\n",
			frames,
			((msi.seconds + (float(msi.minutes * 60))) * 1000.0f) / float(frames)
			);

		for(u32 i(0); i != NUM_SCRIPTS; ++i)
		{
			script[i].Destroy();
		}


	} //r
	//////////////////////////////////////////////////////////////////////////
	ShutdownScriptEngine();

	return r ? 0 : 1;
}
开发者ID:ZoriaRPG,项目名称:ZeldaClassic,代码行数:76,代码来源:ScriptRuntimeUnity.cpp


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