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


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

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


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

示例1: glClear

//------------------------------------------------------------------------------
static void
display() {

    Stopwatch s;
    s.Start();

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glViewport(0, 0, g_width, g_height);
    g_hud.FillBackground();

    double aspect = g_width/(double)g_height;
    identity(g_transformData.ModelViewMatrix);
    translate(g_transformData.ModelViewMatrix, -g_pan[0], -g_pan[1], -g_dolly);
    rotate(g_transformData.ModelViewMatrix, g_rotate[1], 1, 0, 0);
    rotate(g_transformData.ModelViewMatrix, g_rotate[0], 0, 1, 0);
    rotate(g_transformData.ModelViewMatrix, -90, 1, 0, 0);
    translate(g_transformData.ModelViewMatrix,
              -g_center[0], -g_center[1], -g_center[2]);
    perspective(g_transformData.ProjectionMatrix,
                45.0f, (float)aspect, 0.01f, 500.0f);
    multMatrix(g_transformData.ModelViewProjectionMatrix,
               g_transformData.ModelViewMatrix,
               g_transformData.ProjectionMatrix);

    glEnable(GL_DEPTH_TEST);

    drawStencils();

    // draw the control mesh
    g_controlMeshDisplay.Draw(g_stencilOutput->BindSrcBuffer(), 3*sizeof(float),
                              g_transformData.ModelViewProjectionMatrix);

    s.Stop();
    float drawCpuTime = float(s.GetElapsed() * 1000.0f);
    s.Start();
    glFinish();
    s.Stop();
    float drawGpuTime = float(s.GetElapsed() * 1000.0f);

    if (g_hud.IsVisible()) {
        g_fpsTimer.Stop();
        double fps = 1.0/g_fpsTimer.GetElapsed();
        g_fpsTimer.Start();

        g_hud.DrawString(10, -100,  "# stencils   : %d", g_nsamplesDrawn);
        g_hud.DrawString(10, -80,  "EvalStencils : %.3f ms", g_evalTime);
        g_hud.DrawString(10, -60,  "GPU Draw     : %.3f ms", drawGpuTime);
        g_hud.DrawString(10, -40,  "CPU Draw     : %.3f ms", drawCpuTime);
        g_hud.DrawString(10, -20,  "FPS          : %3.1f", fps);

        g_hud.Flush();
    }
    glFinish();

    //checkGLErrors("display leave");
}
开发者ID:AiYong,项目名称:OpenSubdiv,代码行数:57,代码来源:glStencilViewer.cpp

示例2: sin

//------------------------------------------------------------------------------
void
updateGeom() {

    int nverts = (int)g_orgPositions.size() / 3;

    std::vector<float> vertex;
    vertex.reserve(nverts*6);

    const float *p = &g_orgPositions[0];
    const float *n = &g_normals[0];

    float r = sin(g_frame*0.001f) * g_moveScale;
    for (int i = 0; i < nverts; ++i) {
        float move = 0.05f*cosf(p[0]*20+g_frame*0.01f);
        float ct = cos(p[2] * r);
        float st = sin(p[2] * r);
        g_positions[i*3+0] = p[0]*ct + p[1]*st;
        g_positions[i*3+1] = -p[0]*st + p[1]*ct;
        g_positions[i*3+2] = p[2];
        
        p += 3;
    }

    p = &g_positions[0];
    for (int i = 0; i < nverts; ++i) {
        vertex.push_back(p[0]);
        vertex.push_back(p[1]);
        vertex.push_back(p[2]);
        vertex.push_back(n[0]);
        vertex.push_back(n[1]);
        vertex.push_back(n[2]);
        
        p += 3;
        n += 3;
    }

    if (!g_vertexBuffer)
        g_vertexBuffer = g_osdmesh->InitializeVertexBuffer(6);
    g_vertexBuffer->UpdateData(&vertex[0], nverts);

    Stopwatch s;
    s.Start();

    g_osdmesh->Subdivide(g_vertexBuffer, NULL);

    s.Stop();
    g_cpuTime = float(s.GetElapsed() * 1000.0f);
    s.Start();
    g_osdmesh->Synchronize();
    s.Stop();
    g_gpuTime = float(s.GetElapsed() * 1000.0f);

    glBindBuffer(GL_ARRAY_BUFFER, g_vertexBuffer->GetGpuBuffer());
    glBindBuffer(GL_ARRAY_BUFFER, 0);
}
开发者ID:mbdriscoll,项目名称:OpenSubdiv,代码行数:56,代码来源:viewer.cpp

示例3: do_parallel_map

static void do_parallel_map(Stopwatch& sw) {
  // Create a bunch of subcontexts from here and put them in a map
  auto all = create();
  ::ContextMap<size_t> mp;
  for (size_t i = N; i < all.size(); i++)
    mp.Add(i, all[i]);

  // Now the threads that will make progress hard:
  auto proceed = std::make_shared<bool>(true);
  for (size_t i = N; i--;)
    std::thread([proceed, mp] {
      while (*proceed)
        for (const auto& cur : mp)
          ;
    }).detach();
  auto cleanup = MakeAtExit([&] { *proceed = false; });

  std::this_thread::sleep_for(std::chrono::milliseconds(100));

  // Enumerate the map while iteration is underway
  sw.Start();
  for (auto& cur : mp)
    ;
  sw.Stop(n);
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例4: main

int main(int argc, char* argv[])
{
	LinearEquationSystemFactory factory;
	LinearEquationSystemSolver solver;

	for (; n <= nLimit; n *= multiplier)
	{
		float minTime = FLT_MAX;
		for (int attempt = 0; attempt < repeatsNumber; ++attempt)
		{
			LinearEquationSystem* system = factory.Create(n);
			NUMBER* solution = new NUMBER[n];

			stopwatch.Start();			
			solver.Solve(system, solution);
			stopwatch.Stop();

			float elapsedSeconds = stopwatch.GetElapsedSeconds();
			if (elapsedSeconds < minTime)
			{
				minTime = elapsedSeconds;
			}

			bool result = checker.IsCorrectSolution(system, solution);
			printf("Correct: %s \n", result ? "yes" : "no");

			delete system;
			delete []solution;
		}

		printf("N = %d, Elapsed seconds: %f\n", n, minTime);
	}
}
开发者ID:alxmglk,项目名称:jacobi-method,代码行数:33,代码来源:main.cpp

示例5: sin

static void
updateGeom() {

    int nverts = (int)g_orgPositions.size() / 3;

    const float *p = &g_orgPositions[0];

    float r = sin(g_frame*0.001f) * g_moveScale;

    g_positions.resize(nverts*3);

    for (int i = 0; i < nverts; ++i) {
        //float move = 0.05f*cosf(p[0]*20+g_frame*0.01f);
        float ct = cos(p[2] * r);
        float st = sin(p[2] * r);
        g_positions[i*3+0] = p[0]*ct + p[1]*st;
        g_positions[i*3+1] = -p[0]*st + p[1]*ct;
        g_positions[i*3+2] = p[2];
        p+=3;
    }

    Stopwatch s;
    s.Start();

    // update control points
    g_stencilOutput->UpdateData(&g_positions[0], 0, nverts);

    // Update random points by applying point & tangent stencils
    g_stencilOutput->EvalStencils();


    s.Stop();
    g_evalTime = float(s.GetElapsed() * 1000.0f);
}
开发者ID:AiYong,项目名称:OpenSubdiv,代码行数:34,代码来源:glStencilViewer.cpp

示例6: Keyboard

/**
 * @fn Keyboard(unsigned char key, int x, int y)
 * @brief GLUT keyboard callback.
 */ 
void Keyboard(unsigned char key, int x, int y)
{
  switch(key) 
  {
  case 'q':
  case 'Q':
  case 27:
    Shutdown();
    exit(0);
  	break;
  case '.':
    g_bSingleStep = true;
    break;
  case 'p':
    g_bPause = !g_bPause;
    break;
  case 'a':
    g_bArbitraryBC = !g_bArbitraryBC;
    g_pFlo->EnableArbitraryBC(g_bArbitraryBC);
    break;
  case 'c':
    g_bClearPressure = !g_bClearPressure;
    g_pFlo->EnablePressureClear(g_bClearPressure);
    break;
  case 'r':
    g_pFlo->Reset();
    break;
  case 'R':
    g_pFlo->Reset(true);
    break;
  case 'v':
    g_bComputeVorticity = !g_bComputeVorticity;
    g_pFlo->EnableVCForce(g_bComputeVorticity);
    break;
  case '~':
  case '`':
    g_bDisplaySliders = !g_bDisplaySliders;
    break;
  case 't':
    g_displayMode = static_cast<Flo::DisplayMode>(((g_displayMode + 1) 
												  % Flo::DISPLAY_COUNT));
    break;
  case 'T':
	g_bDisplayFluid = !g_bDisplayFluid;
	break;
  case 'b':
    g_bBilerp = !g_bBilerp;
    break;
  case 'm':
    g_bMakeTex = !g_bMakeTex;
    break;
  case 'L':
      g_perfTimer.Stop();
      g_perfTimer.Reset();
      g_bTiming = true;
      break;
  default:
    break;
  }
}
开发者ID:hunduan2018,项目名称:GPU-Gems,代码行数:64,代码来源:main.cpp

示例7: Run

void Application::Run()
{
	Stopwatch watch;

	// 理想状况 60 帧每秒
	const DWORD desiredDelta = 1000 / 30;
	// 上一次每帧用时
	DWORD lastDelta = desiredDelta;
	while (true)
	{
		try
		{
			watch.Restart();
			if (DoFrame()) break;
			// 本帧用时
			lastDelta = static_cast<DWORD>(watch.Stop() * 1000);
			// Sleep 剩余时间
			if (lastDelta < desiredDelta)
				Sleep(desiredDelta - lastDelta);
		}
		catch (...)
		{
			bool handled = false;
			OnUncaughtException(handled);
			// 异常未处理
			if (!handled)
				throw;
		}
	}
}
开发者ID:horatii,项目名称:MPF,代码行数:30,代码来源:Application.cpp

示例8: benchNoCachingNoVector

int benchNoCachingNoVector(Vector3D<Precision> const &point, Vector3D<Precision> const &dir,
                           std::vector<Vector3D<Precision>> const &corners
#ifdef SORTHITBOXES
                           ,
                           Container_t &hitlist
#endif
                           )
{
#ifdef INNERTIMER
  Stopwatch timer;
  timer.Start();
#endif
  int vecsize  = corners.size() / 2;
  int hitcount = 0;
  for (auto box = 0; box < vecsize; ++box) {
    double distance = BoxImplementation<translation::kIdentity, rotation::kIdentity>::Intersect(
        &corners[2 * box], point, dir, 0, vecgeom::kInfLength);
    if (distance < vecgeom::kInfLength) {
      hitcount++;
#ifdef SORTHITBOXES
      hitlist.push_back(BoxIdDistancePair_t(box, distance));
#endif
    }
  }
#ifdef INNERTIMER
  timer.Stop();
  std::cerr << "# ORDINARY hitting " << hitcount << "\n";
  std::cerr << "# ORDINARY timer " << timer.Elapsed() << "\n";
#endif
  return hitcount;
}
开发者ID:amadio,项目名称:vecgeom,代码行数:31,代码来源:ABBoxBenchmark.cpp

示例9: accum

__attribute__((noinline)) void benchNavigatorNoReloc(VNavigator const *se, SOA3D<Precision> const &points,
                                                     SOA3D<Precision> const &dirs, NavStatePool const &inpool,
                                                     NavStatePool &outpool)
{
  Precision *steps = new Precision[points.size()];
  Precision *safeties;
  if (WithSafety) safeties = new Precision[points.size()];
  Stopwatch timer;
  size_t hittargetchecksum = 0L;
  timer.Start();
  for (decltype(points.size()) i = 0; i < points.size(); ++i) {
    if (WithSafety) {
      steps[i] = se->ComputeStepAndSafety(points[i], dirs[i], vecgeom::kInfLength, *inpool[i], true, safeties[i]);
    } else {
      steps[i] = se->ComputeStep(points[i], dirs[i], vecgeom::kInfLength, *inpool[i], *outpool[i]);
    }
  }
  timer.Stop();
  std::cerr << timer.Elapsed() << "\n";
  double accum(0.), saccum(0.);
  for (decltype(points.size()) i = 0; i < points.size(); ++i) {
    accum += steps[i];
    if (WithSafety) {
      saccum += safeties[i];
    }
    if (outpool[i]->Top()) hittargetchecksum += (size_t)outpool[i]->Top()->id();
  }
  delete[] steps;
  std::cerr << "accum  " << se->GetName() << " " << accum << " target checksum " << hittargetchecksum << "\n";
  if (WithSafety) {
    std::cerr << "saccum  " << se->GetName() << " " << saccum << "\n";
  }
}
开发者ID:amadio,项目名称:vecgeom,代码行数:33,代码来源:NavigationKernelBenchmarker.cpp

示例10: Test1

void Test1()
{
    DIVIDING_LINE_1('-');

    constexpr int Count = 2001001;

#if HAS_BOOST
    boost::recursive_mutex osMutex;
    ostream_t os(std::cout, osMutex);
#else
    ostream_t &os = std::cout;
#endif

    Stopwatch sw;
    sw.Start();

    ProducerConsumerContext context(os, Count, Count / 10, ENABLE_LOGGING);

    Producer p1(context, 0, Count / 2, 200);
    Producer p2(context, Count / 2, Count - Count / 2, 200);

    Consumer c1(context, Count / 3, 200);
    Consumer c2(context, Count / 3, 200);
    Consumer c3(context, Count - Count / 3 - Count / 3, 200);

    std::vector<std::thread> threads;
    threads.push_back(p1.Create());
    threads.push_back(p2.Create());
    threads.push_back(c1.Create());
    threads.push_back(c2.Create());
    threads.push_back(c3.Create());

    for (auto &t : threads)
        t.join();

    sw.Stop();
    std::cout << "Ellapsed time: " << sw.GetElapsedMilliseconds() << "ms" << std::endl;

    std::cout << "Checking if test is passed...\n";

    sw.Restart();
    bool ok = context.IsTestPassed();
    sw.Stop();

    std::cout << "It takes " << sw.GetElapsedMilliseconds() << "ms to figure out if test is passed." << std::endl;
    std::cout << "Is test passed? " << std::boolalpha << ok << std::endl;
}
开发者ID:myd7349,项目名称:Ongoing-Study,代码行数:47,代码来源:ProducerConsumerProblemCpp11v2.cpp

示例11: DoAll

//-------------------------------------------------------------------------------------------------
void Benchmark::DoAll(std::vector<string> vExpr, long num)
{
   printf("\n\n\n");

   PreprocessExpr(vExpr);

   char outstr[400], file[400];
   time_t t = time(NULL);

   #ifdef _DEBUG
   sprintf(outstr, "Bench_%s_%%Y%%m%%d_%%H%%M%%S_dbg.txt", GetShortName().c_str());
   #else
   sprintf(outstr, "Bench_%s_%%Y%%m%%d_%%H%%M%%S_rel.txt", GetShortName().c_str());
   #endif

   strftime(file, sizeof(file), outstr, localtime(&t));

   FILE *pRes = fopen(file, "w");
   assert(pRes);

   fprintf(pRes,  "# Benchmark results\n");
   fprintf(pRes,  "#   Parser:  %s\n", GetName().c_str());
   fprintf(pRes,  "#   Evals per expr:  %ld\n", num);
   fprintf(pRes,  "#\"ms per eval [ms]\", \"evals per sec\", \"Result\", \"expr_len\", \"Expression\"\n");

   std::string sExpr;

   Stopwatch timer;
   timer.Start();
   for (std::size_t i = 0; i < vExpr.size(); ++i)
   {
      try
      {
         DoBenchmark(vExpr[i], num);
         fprintf(pRes, "%4.6lf, %4.6lf, %4.6lf, %d, %s, %s\n", m_fTime1, 1000.0/m_fTime1, m_fResult, (int)vExpr[i].length(), vExpr[i].c_str(), m_sInfo.c_str());
         printf(       "%4.6lf, %4.6lf, %4.6lf, %d, %s, %s\n", m_fTime1, 1000.0/m_fTime1, m_fResult, (int)vExpr[i].length(), vExpr[i].c_str(), m_sInfo.c_str());
      }
      catch(...)
      {
         fprintf(pRes, "fail: %s\n", vExpr[i].c_str());
         printf(       "fail: %s\n", vExpr[i].c_str());
      }

      fflush(pRes);
   }
   double dt = timer.Stop() / ((double)vExpr.size() * num);

   fprintf(pRes,  "# avg. time per expr.: %lf ms;  avg. eval per sec: %lf; total bytecode size: %d",
           dt,
           1000.0 / dt,
           m_nTotalBytecodeSize);

   printf("\n#\n# avg. time per expr.: %lf ms;  avg. eval per sec: %lf; total bytecode size: %d",
          dt,
          1000.0 / dt,
          m_nTotalBytecodeSize);

   fclose(pRes);
}
开发者ID:tomilov,项目名称:math-parser-benchmark-project,代码行数:60,代码来源:Benchmark.cpp

示例12: collider

	void playback_exact_CSpace_R3()
	{
		C2A_Model* P = NULL;
		C2A_Model* Q = NULL;
		readObjFile(P, "../data/models/CupSpoon/Cup.obj");
		readObjFile(Q, "../data/models/CupSpoon/Spoon.obj");

		P->ComputeRadius();
		Q->ComputeRadius();

		Collider3D collider(P, Q);

		C2A_Model* CSpace;
		readObjFile(CSpace, "../data/cupspoon.obj");

		std::vector<ContactSpaceSampleData> contactspace_samples;
		std::ifstream in("space_test_3d.txt");
		asciiReader(in, contactspace_samples);

		std::ofstream timing_file("timing_exact_R3.txt");
		std::ofstream PD_file("PD_exact_R3.txt");

		for(std::size_t i = 0; i < contactspace_samples.size(); ++i)
		{
			std::cout << i << std::endl;
			DataVector q_col(6);
			DataVector q(3);
			for(std::size_t j = 0; j < 3; ++j)
				q[j] = contactspace_samples[i].v[j];

			for(std::size_t j = 0; j < 6; ++j)
				q_col[j] = contactspace_samples[i].v[j];


			boost::timer t;
			//aTimer.Reset();
			aTimer.Start();
			std::pair<DataVector, double> pd_result;
			if(!collider.isCollide(q_col)) 
			{
				pd_result.second = 0;
			}
			else
			{
				pd_result = Minkowski_Cspace_3D::Exact_PD_R3(q, CSpace);
			}
			aTimer.Stop();
			PD_file << pd_result.second << " ";	
			//timing_file << t.elapsed() << " ";
			timing_file << aTimer.GetTime() * 1000 << " ";

			
			timing_file.flush();
			PD_file.flush();
		}
	}
开发者ID:panjia1983,项目名称:APDL,代码行数:56,代码来源:playback_cupspoon.cpp

示例13: ReportTestFinish

void MyPerformanceReporter::ReportTestFinish(UnitTest::TestDetails const& test, float secondsElapsed)
{
    Counter.Stop();

    if (lastsuitename != test.suiteName) {
        outputFile << endl << endl << test.suiteName <<endl;
        lastsuitename = test.suiteName;
    }
    outputFile << test.testName << ";" << (secondsElapsed*1000) << "ms" << endl;

}
开发者ID:ByeDream,项目名称:pixellight,代码行数:11,代码来源:MyPerformanceReporter.cpp

示例14:

double
OsdMesh::Synchronize() {

    Stopwatch s;
    s.Start();
    {
        _dispatcher->Synchronize();
    }
    s.Stop();

    return s.GetElapsed();
}
开发者ID:mbdriscoll,项目名称:OpenSubdiv,代码行数:12,代码来源:mesh.cpp

示例15: main

int main()
{
    // Stopwatch object used to measure time intervals
    Stopwatch sw;   

    // Record start time
    sw.Start();
    
    // Portion of code to be timed
    ::Sleep(1000);  // Just wait for 1,000 ms (1 second)
    
    // Record end time
    sw.Stop();

    // Print timing results
    cout << "Elapsed time: " << sw.ElapsedMilliseconds() << " ms\n";
}
开发者ID:GiovanniDicanio,项目名称:StopwatchWin32,代码行数:17,代码来源:StopwatchTest.cpp


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