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


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

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


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

示例1: SplitIntoLines

		GLProgram *GLProgramManager::CreateProgram(const std::string &name) {
			SPADES_MARK_FUNCTION();

			SPLog("Loading GLSL program '%s'", name.c_str());
			std::string text = FileManager::ReadAllBytes(name.c_str());
			std::vector<std::string> lines = SplitIntoLines(text);

			GLProgram *p = new GLProgram(device, name);

			for (size_t i = 0; i < lines.size(); i++) {
				std::string text = TrimSpaces(lines[i]);
				if (text.empty())
					break;

				if (text == "*shadow*") {
					std::vector<GLShader *> shaders =
					  GLShadowShader::RegisterShader(this, settings, false);
					for (size_t i = 0; i < shaders.size(); i++)
						p->Attach(shaders[i]);
					continue;
				} else if (text == "*shadow-lite*") {
					std::vector<GLShader *> shaders =
					  GLShadowShader::RegisterShader(this, settings, false, true);
					for (size_t i = 0; i < shaders.size(); i++)
						p->Attach(shaders[i]);
					continue;
				} else if (text == "*shadow-variance*") {
					std::vector<GLShader *> shaders =
					  GLShadowShader::RegisterShader(this, settings, true);
					for (size_t i = 0; i < shaders.size(); i++)
						p->Attach(shaders[i]);
					continue;
				} else if (text == "*dlight*") {
					std::vector<GLShader *> shaders = GLDynamicLightShader::RegisterShader(this);
					for (size_t i = 0; i < shaders.size(); i++)
						p->Attach(shaders[i]);
					continue;
				} else if (text == "*shadowmap*") {
					std::vector<GLShader *> shaders = GLShadowMapShader::RegisterShader(this);
					for (size_t i = 0; i < shaders.size(); i++)
						p->Attach(shaders[i]);
					continue;
				} else if (text[0] == '*') {
					SPRaise("Unknown special shader: %s", text.c_str());
				} else if (text[0] == '#') {
					continue;
				}
				GLShader *s = CreateShader(text);

				p->Attach(s);
			}

			Stopwatch sw;
			p->Link();
			SPLog("Successfully linked GLSL program '%s' in %.3fms", name.c_str(),
			      sw.GetTime() * 1000.);
			// p->Validate();
			return p;
		}
开发者ID:Rootmars,项目名称:openspades,代码行数:59,代码来源:GLProgramManager.cpp

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

示例3: doPerfTest

void doPerfTest(int n_runs)
{
  printf("Running perf test (%d runs)...\n", n_runs);

  if(n_runs == 0) return;

  buildProjectionMatrix();
  resetDepthBuffer();
  piko_pipe.prepare();
  piko_pipe.run_single();

  Stopwatch mywatch;

  mywatch.Reset();
  for(int run = 0; run < n_runs; run++)
  {
    buildProjectionMatrix();
    resetDepthBuffer();
    piko_pipe.prepare();
  }
  float prepTime = mywatch.GetTime();

  mywatch.Reset();
  for(int run = 0; run < n_runs; run++)
  {
    buildProjectionMatrix();
    resetDepthBuffer();
    piko_pipe.prepare();
    piko_pipe.run_single();
  }
  float fullrunTime = mywatch.GetTime();

  float total_time_to_ms = 1000.0f / (float) n_runs;

  printf("Prep time     = %0.2f ms\n", total_time_to_ms * (prepTime));
  printf("Full run time = %0.2f ms\n", total_time_to_ms * (fullrunTime));
  printf("Raster time   = %0.2f ms\n", total_time_to_ms * (fullrunTime - prepTime));
}
开发者ID:c0d1f1ed,项目名称:piko-public,代码行数:38,代码来源:main.cpp

示例4: if

		GLShader *GLProgramManager::CreateShader(const std::string &name) {
			SPADES_MARK_FUNCTION();

			SPLog("Loading GLSL shader '%s'", name.c_str());
			std::string text = FileManager::ReadAllBytes(name.c_str());
			GLShader::Type type;

			if (name.find(".fs") != std::string::npos)
				type = GLShader::FragmentShader;
			else if (name.find(".vs") != std::string::npos)
				type = GLShader::VertexShader;
			else if (name.find(".gs") != std::string::npos)
				type = GLShader::GeometryShader;
			else
				SPRaise("Failed to determine the type of a shader: %s", name.c_str());

			GLShader *s = new GLShader(device, type);

			std::string finalSource;

			if (settings.r_hdr) {
				finalSource += "#define USE_HDR 1\n";
				finalSource += "#define LINEAR_FRAMEBUFFER 1\n";
			} else {
				finalSource += "#define USE_HDR 0\n";
				finalSource += "#define LINEAR_FRAMEBUFFER 0\n";
			}
			if (settings.r_fogShadow) {
				finalSource += "#define USE_VOLUMETRIC_FOG 1\n";
			} else {
				finalSource += "#define USE_VOLUMETRIC_FOG 0\n";
			}

			if (settings.r_ssao) {
				finalSource += "#define USE_SSAO 1\n";
			} else {
				finalSource += "#define USE_SSAO 0\n";
			}

			finalSource += text;

			s->AddSource(finalSource);

			Stopwatch sw;
			s->Compile();
			SPLog("Successfully compiled GLSL program '%s' in %.3fms", name.c_str(), // should this be "program" or "shader"?
			      sw.GetTime() * 1000.);
			return s;
		}
开发者ID:Rootmars,项目名称:openspades,代码行数:49,代码来源:GLProgramManager.cpp

示例5: timing_file

	void playback_local_PD_R3()
	{
		std::ofstream timing_file("timing_local_PD_R3.txt");
		std::ofstream PD_file("PD_local_R3.txt");

		std::vector<C2A_Model*> P;
		std::vector<C2A_Model*> Q;

		readObjFiles(P, "../data/models/CupSpoon/cup_convex.obj");
		readObjFiles(Q, "../data/models/CupSpoon/spoon_convex.obj");


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

		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();
			double pd = Collider3D::PDt(P, Q, q_col);
			PD_file << pd << " ";	
			// timing_file << t.elapsed() << " ";
			timing_file << aTimer.GetTime() * 1000 << " ";

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

示例6: if

		GLShader *GLProgramManager::CreateShader(const std::string &name) {
			SPADES_MARK_FUNCTION();
			
			SPLog("Loading GLSL shader '%s'", name.c_str());
			std::string text = FileManager::ReadAllBytes(name.c_str());
			GLShader::Type type;
			
			if(name.find(".fs") != std::string::npos)
				type = GLShader::FragmentShader;
			else if(name.find(".vs") != std::string::npos)
				type = GLShader::VertexShader;
			else
				SPRaise("Failed to determine the type of a shader: %s",
						name.c_str());
			
			GLShader *s = new GLShader(device, type);
			s->AddSource(text);
			
			Stopwatch sw;
			s->Compile();
			SPLog("Successfully compiled GLSL program '%s' in %.3fms", name.c_str(),
				  sw.GetTime() * 1000.);
			return s;
		}
开发者ID:AEM7,项目名称:openspades-1,代码行数:24,代码来源:GLProgramManager.cpp

示例7: main

int main(int argc, char* argv[])
{
	string trainlistfile;
	string testlistfile;
	string modelfile;
	string rawfeaturefile;
	string resultpath;
	string kmeansfilepath;
	int maxComponent = 32;
	int cluster_num = 512;
	int feature_dimention = 128;
	if (argc == 1)
	{
		help();
		return -1;
	}
	for (int i = 1; i < argc;++i)
	{
		
		if (string(argv[i])=="--trainlist")
		{
			trainlistfile = argv[++i];
		}
		else if (string(argv[i]) == "--testlist")
		{
			testlistfile = argv[++i];
		}
		else if (string(argv[i]) == "--clusternum")
		{
			cluster_num = std::stoi(argv[++i]);
		}
		else if (string(argv[i]) == "--featuredim")
		{
			feature_dimention = std::stoi(argv[++i]);
		}
		else if (string(argv[i]) == "--modelfile")
		{
			modelfile = argv[++i];
		}
		else if (string(argv[i]) == "--rawfeature")
		{
			rawfeaturefile = argv[++i];
		}
		else if (string(argv[i])=="--resultpath")
		{
			resultpath = argv[++i];

		}
		else if (string(argv[i]) == "--maxComponent")
		{
			maxComponent = std::stoi(argv[++i]);

	}
		else if (string(argv[i]) == "--kmeansfilepath")
		{
			kmeansfilepath = argv[++i];

		}
	}
#ifdef kmeans_pca
	vlad::configure(256,128);
	PCA pca;
	vlad::loadPCAmodel("pca_model.yml",pca);
	cout<<pca.eigenvalues<<endl;
#endif
#ifdef kmeans
	vlad::getKmeansModel(cluster_num,feature_dimention,rawfeaturefile,resultpath);
#endif
#ifdef VLAD
	Stopwatch watch;
	watch.Start();
	vlad::GetVladFeatureFromSift(kmeansfilepath,testlistfile);
	watch.Stop();
	cout<<"getkmeans use "<<watch.GetTime()<<endl;
	getchar();
#endif
#ifdef ReduceMatrix
	ifstream rawfeature(rawfeaturefile.c_str());
	ofstream outPut(resultpath.c_str());
	string single_raw_fea;
	PCA pca;
	vlad::loadPCAmodel(modelfile, pca);
	while (getline(rawfeature,single_raw_fea))
	{
		vector<string> ww;
		cv::Mat rawfeature_mat = cv::Mat(1,LENGTH_OF_SINGLE_DATA, CV_32F);
		split_words(single_raw_fea, " ", ww);
		for (int j = 0; j < LENGTH_OF_SINGLE_DATA; ++j){
			rawfeature_mat.at<float>(0, j) = atof(ww[j].c_str());
		}
		cv::Mat matric_reduced;
		matric_reduced = pca.project(rawfeature_mat);
		for (int i=0;i<matric_reduced.cols;++i)
		{
			outPut<<matric_reduced.at<float>(0,i);
		}
		outPut <<endl;
        
	}
	rawfeature.close();
//.........这里部分代码省略.........
开发者ID:lzx1413,项目名称:image_feature,代码行数:101,代码来源:main.cpp

示例8: Display

/**
 * @fn Display()
 * @brief GLUT display callback.
 */ 
void Display()
{
  //g_timer.Reset();

  if (!g_bPause || g_bSingleStep)
  {
    g_bSingleStep = false;
     
    // set parameters that may have changed
    g_pFlo->SetViscosity(g_rViscosity);
    g_pFlo->EnablePressureClear(g_bClearPressure);
    g_pFlo->SetNumPoissonSteps(g_iNumPoissonSteps);
    g_pFlo->SetMassColor(g_rInkRGB);
    g_pFlo->SetInkLongevity(g_rInkLongevity);
    g_pFlo->SetTimeStep(g_rTimestep);
    g_pFlo->SetGridScale(g_rGridScale);
    g_pFlo->SetVorticityConfinementScale(g_rVCScale);
    
    if (g_displayMode == Flo::DISPLAY_VORTICITY || g_bComputeVorticity)
      g_pFlo->EnableVorticityComputation(true);
    else
      g_pFlo->EnableVorticityComputation(false);
    
	// For benchmarking...
    if (g_bTiming)
    {
      if (g_perfTimer.GetNumStarts() == 100)
      {
        g_bTiming = false;
        g_perfTimer.Stop();
        printf("Average iteration time: %f\n", g_perfTimer.GetAvgTime());
      }
      g_perfTimer.Start();
    }

	// Take a simulation timestep.
    g_pFlo->Update();
  }
  
  if (g_bDisplayFluid)
  {
	// Display the fluid.
	g_pFlo->Display(g_displayMode, g_bBilerp, g_bMakeTex, g_bArbitraryBC);
	  
	// Display user interface.
	if (g_bDisplaySliders)
	{
	  paramlist->Render(0, 0);
	}
	  
	glutSwapBuffers();
  }
  
  // Frame rate update
  g_iFrameCount++;
  
  if (g_timer.GetTime() > 0.5)
  {  
    char title[100];
    sprintf(title, "Flo Fluid Simulator: %f FPS", 
			g_iFrameCount / g_timer.GetTime());
    glutSetWindowTitle(title);

    g_iFrameCount = 0;
    g_timer.Reset();
  }

}
开发者ID:hunduan2018,项目名称:GPU-Gems,代码行数:72,代码来源:main.cpp


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