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


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

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


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

示例1: sa

template <class T> bool
karbtest (Connector<T>* rc) {

	GradientParams gp;

	std::string in_file;// = std::string (base + "/" + std::string(rc->GetElement("/config/data-in")->Attribute("fname")));
	std::string out_file;// = std::string (base + "/" + rc->GetElement("/config/data-out")->Attribute("fname"));

	bool   simann  = false;
	size_t hpoints = 1;
	rc->Attribute ("simann",   &simann);
	rc->Attribute ("hpoints",  &hpoints);

	if (simann) {

		double coolrate, startt, finalt;
		size_t coolit;
		bool   verbose, exchange;
		
		rc->Attribute ("coolrate", &coolrate);
		rc->Attribute ("startt",   &startt);
		rc->Attribute ("finalt",   &finalt);
		rc->Attribute ("coolit",   &coolit);
		rc->Attribute ("verbose",  &verbose);
		rc->Attribute ("exchange", &exchange);
		
		SimulatedAnnealing sa (gp.k, coolit, startt, finalt, coolrate, verbose, exchange);
		sa.Cool();
		gp.k = sa.GetSolution();
		
	}
	
	rc->Attribute ("maxgrad", &(gp.mgr));
	rc->Attribute ("maxslew", &(gp.msr));
	rc->Attribute ("dt",      &(gp.dt));
	
	rc->Attribute ("gunits",  &(gp.gunits));
	rc->Attribute ("lunits",  &(gp.lunits));
	
	Matrix<double> x  = linspace<double> (0.0,1.0,size(gp.k,0));
	Matrix<double> xi = linspace<double> (0.0,1.0,size(gp.k,0)*hpoints);

	gp.k = interp1 (x, gp.k, xi, INTERP::AKIMA);

	printf ("\nComputing trajectory for ... \n");
	printf ("    [maxgrad: %.2f, maxslew: %.2f, dt: %.2e]\n\n", gp.mgr, gp.msr, gp.dt);
	
    SimpleTimer st ("VD spiral design");
	Solution s = ComputeGradient (gp);
    st.Stop();
	
    IOContext f = fopen (out_file.c_str(), WRITE);
    s.dump (f);
    fclose (f);
	

	return true;

}
开发者ID:nomissretep,项目名称:codeare,代码行数:59,代码来源:karb.hpp

示例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


//.........这里部分代码省略.........
        if (hStdError[i] == INVALID_HANDLE_VALUE)
        {
            LogError("Unable to open '%s'. GetLastError()=%u", arrStdErrorPath[i], GetLastError());
            return -1;
        }

        //Create a SuperPMI worker process and redirect its output to file
        if (!StartProcess(cmdLine, hStdOutput[i], hStdError[i], &hProcesses[i]))
        {
            return -1;
        }
    }

    WaitForMultipleObjects(o.workerCount, hProcesses, true, INFINITE);

    // Close stdout/stderr
    for (int i = 0; i < o.workerCount; i++)
    {
        CloseHandle(hStdOutput[i]);
        CloseHandle(hStdError[i]);
    }

    DWORD exitCode = 0; // 0 == assume success

    if (!closeRequested)
    {
        // Figure out the error code to use. We use the largest magnitude error code of the children.
        // Mainly, if any child returns non-zero, we want to return non-zero, to indicate failure.
        for (int i = 0; i < o.workerCount; i++)
        {
            DWORD exitCodeTmp;
            BOOL ok = GetExitCodeProcess(hProcesses[i], &exitCodeTmp);
            if (ok && (exitCodeTmp > exitCode))
            {
                exitCode = exitCodeTmp;
            }
        }

        bool usageError = false; //variable to flag if we hit a usage error in SuperPMI

        int loaded = 0, jitted = 0, failed = 0, diffs = 0;

        //Read the stderr files and log them as errors
        //Read the stdout files and parse them for counts and log any MISSING or ISSUE errors
        for (int i = 0; i < o.workerCount; i++)
        {
            ProcessChildStdErr(arrStdErrorPath[i]);
            ProcessChildStdOut(o, arrStdOutputPath[i], &loaded, &jitted, &failed, &diffs, &usageError);
            if (usageError)
                break;
        }

        if (o.mclFilename != nullptr && !usageError)
        {
            //Concat the resulting .mcl files
            MergeWorkerMCLs(o.mclFilename, arrFailingMCListPath, o.workerCount);
        }

        if (o.diffMCLFilename != nullptr && !usageError)
        {
            //Concat the resulting diff .mcl files
            MergeWorkerMCLs(o.diffMCLFilename, arrDiffMCListPath, o.workerCount);
        }

        if (!usageError)
        {
            if (o.applyDiff)
            {
                LogInfo(g_AsmDiffsSummaryFormatString, loaded, jitted, failed, diffs);
            }
            else
            {
                LogInfo(g_SummaryFormatString, loaded, jitted, failed);
            }
        }

        st.Stop();
        LogVerbose("Total time: %fms", st.GetMilliseconds());
    }

    if (!o.skipCleanup)
    {
        // Delete all temporary files generated
        for (int i = 0; i < o.workerCount; i++)
        {
            if (arrFailingMCListPath[i] != nullptr)
            {
                DeleteFile(arrFailingMCListPath[i]);
            }
            if (arrDiffMCListPath[i] != nullptr)
            {
                DeleteFile(arrDiffMCListPath[i]);
            }
            DeleteFile(arrStdOutputPath[i]);
            DeleteFile(arrStdErrorPath[i]);
        }
    }

    return (int)exitCode;
}
开发者ID:bretambrose,项目名称:coreclr,代码行数:101,代码来源:parallelsuperpmi.cpp


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