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


C++ StopWatch::ElapsedSeconds方法代码示例

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


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

示例1: TestLoggingOverhead_SingleThreaded_noSynchronisation1

int TestLoggingOverhead_SingleThreaded_noSynchronisation1() {
	// First initialization, using defaults from Boost logging.
	BoostLogging::InitAddCommonAttributes();
	BoostLogging::InitSetLogLevelToDebug();
	BoostLogging::InitLogToDevNull();
	const int max = 1000000;
	{
		// trace messages are dropped, because min level is debug
		bool complexTraceMessage = false;
		StopWatch stopWatch;
		BoostLogging::LogTraceMessageManyTimes(max, complexTraceMessage);
		std::cout << "Simple trace message: elapsed time: " << stopWatch.ElapsedSeconds().count()
				<< ", max: " << max << std::endl;
	}
	{
	  // trace messages are dropped, because min level is debug
		bool complexTraceMessage = true;
		StopWatch stopWatch;
		BoostLogging::LogTraceMessageManyTimes(max, complexTraceMessage);
		std::cout << "Complex Trace message: elapsed time: " << stopWatch.ElapsedSeconds().count()
				<< ", max: " << max << std::endl;
	}
	{
	  // debug messages are processed and written to /dev/null, because min level is debug
		StopWatch stopWatch;
		BoostLogging::LogDebugMessageManyTimes(max);
		std::cout << "Writing debug message to /dev/null unsynchronized(1)): elapsed time: " << stopWatch.ElapsedSeconds().count()
				<< ", max: " << max << std::endl;
	}
	return OutcomeIsOk();
开发者ID:robertjacobs,项目名称:mahusandbox,代码行数:30,代码来源:testBoostLogging.cpp

示例2: TestLoggingOverhead_SingleThreaded_Synchronisation

int TestLoggingOverhead_SingleThreaded_Synchronisation() {
	// First initialization, using defaults from Boost logging.
	BoostLogging::InitAddCommonAttributes();
	BoostLogging::InitSetLogLevelToDebug();
	BoostLogging::InitLogToDevNullSynchronized();
	const int max = 1000000;
	{
	  // debug messages are processed and written to /dev/null, because min level is debug
		StopWatch stopWatch;
		BoostLogging::LogDebugMessageManyTimes(max);
		std::cout << "Writing debug message to /dev/null synchronized): elapsed time: " << stopWatch.ElapsedSeconds().count()
				<< ", max: " << max << std::endl;
	}
	return OutcomeIsOk();
开发者ID:robertjacobs,项目名称:mahusandbox,代码行数:14,代码来源:testBoostLogging.cpp

示例3: main_test

int main_test(){
  Context context;
  StopWatch swatch;
  World world;
  CameraControl ev;
  glPointSize(2.0);
  ev.cam.position = vec(0.0f,0.0f,5.0f);
  mouse_move_spawner.register_listener(&ev);
  key_event_handler.register_listener(&ev);
  
  FlatShader3D flat;
  flat.SetProjection(ProjectionMatrix(0.01,0.01,0.01,200000.0));
  
  GameObject * go = new GameObjectTest(context);
  
  go->GravityBound = false;
  go->aabb.pos[0] += 0.1;
  go->aabb.pos[2] += 0.1;
  go->aabb.pos[1] -= 4.0;
  go->aabb.size = vec(20.0,2.0,20.0);
  go->aabb.mass = 100000.0;
  go->Tetra.TRS = TMatrix(vec(10.0f,0.0f,10.0f)) * SMatrix(vec(10.0f,1.0f,10.0f));
  world.InsertObject(go);

  go = new GameObjectTest(context);
  go->GravityBound = false;
  go->aabb.size = vec(2.0,2.0,2.0);
  go->Tetra = Tetragon();
  world.InsertObject(go);
  VBO stars = context.Stars;
  while(true){
    Matrix<float,4> cameraMatrix;
    go->aabb.pos = -ev.cam.position.As<double>() - vec(0.0,0.0,0.0);
    print(go->aabb.pos);
    auto goList = world.GetNearbyObjects(vec(0.0,0.0,0.0),5000000.0);
    world.PhysicsUpdate(vec(0.0,0.0,0.0),500000,0.1);

    for(auto go : goList){
      go.Get()->DoUpdate(world);
    }

    //ev.cam.position = go->aabb.pos.As<float>() + vec(0.0f,-2.0f,0.0f);
    print(go->aabb.pos);
    swatch.Reset();
    swatch.Start();
    ClearBuffer(vec(0.0f,0.0f,0.0f,1.0f));
    cameraMatrix = ev.GetCamera().getTransformMatrix();
    /*cameraMatrix[3][0] = 0;
    cameraMatrix[3][1] = 0;
    cameraMatrix[3][2] = 0;
    */
    flat.SetCamera(cameraMatrix);   
    
    flat.SetModelView(Matrix<float,4>::Eye());
    context.StarColors.Bind(0);
    stars.BindBuffer(0);
    VertexBufferObject::DrawBuffers(DrawMethod::Points,100);
    flat.SetCamera(ev.GetCamera().getTransformMatrix());   
    goList = world.GetNearbyObjects(vec(0.0,0.0,0.0),5000000.0);
    for(auto go: goList){
      go.Get()->Draw(flat);
    }
    SwapBuffers();
    Sleep(1/30.0 - swatch.ElapsedSeconds());
  }
}
开发者ID:rolfrm,项目名称:epiclib,代码行数:66,代码来源:octree_demo.cpp

示例4: TrainIteration

    void Trainer::TrainIteration(DataBlockBase* data_block)
    {
        StopWatch watch; watch.Start();
        LDADataBlock* lda_data_block =
            reinterpret_cast<LDADataBlock*>(data_block);

        DataBlock& data = lda_data_block->data();
        int32_t block = lda_data_block->block();
        int32_t slice = lda_data_block->slice();
        int32_t iter = lda_data_block->iteration();
        const LocalVocab& local_vocab = data.meta();
        
        int32_t id = TrainerId();
        int32_t trainer_num = TrainerCount();
        int32_t lastword = local_vocab.LastWord(slice);
        if (id == 0)
        {
            Log::Info("Rank = %d, Iter = %d, Block = %d, Slice = %d\n",
                Multiverso::ProcessRank(), lda_data_block->iteration(),
                lda_data_block->block(), lda_data_block->slice());
        }
        // Build Alias table
        if (id == 0) alias_->Init(meta_->alias_index(block, slice));
        barrier_->Wait();
        for (const int32_t* pword = local_vocab.begin(slice) + id;
            pword < local_vocab.end(slice);
            pword += trainer_num)
        {
            alias_->Build(*pword, this);
        }
        if (id == 0) alias_->Build(-1, this);
        barrier_->Wait();

        if (TrainerId() == 0)
        {
            Log::Info("Rank = %d, Alias Time used: %.2f s \n",
                Multiverso::ProcessRank(), watch.ElapsedSeconds());
        }
        int32_t num_token = 0;
        watch.Restart();
        // Train with lightlda sampler
        for (int32_t doc_id = id; doc_id < data.Size(); doc_id += trainer_num)
        {
            Document* doc = data.GetOneDoc(doc_id);
            num_token += sampler_->SampleOneDoc(doc, slice, lastword, this, alias_);
        }
        if (TrainerId() == 0)
        {
            Log::Info("Rank = %d, Training Time used: %.2f s \n", 
                Multiverso::ProcessRank(), watch.ElapsedSeconds());
            Log::Info("Rank = %d, sampling throughput: %.6f (tokens/thread/sec) \n", 
                Multiverso::ProcessRank(), double(num_token) / watch.ElapsedSeconds());
        }
        watch.Restart();
        // Evaluate loss function
        // Evaluate(lda_data_block);
        
        if (iter % 5 == 0)
        {
            Evaluate(lda_data_block);
            if (TrainerId() == 0)
                Log::Info("Rank = %d, Evaluation Time used: %.2f s \n",
                    Multiverso::ProcessRank(), watch.ElapsedSeconds());
        }
        // if (iter != 0 && iter % 50 == 0) Dump(iter, lda_data_block);

        // Clear the thread information in alias table
        if (iter == Config::num_iterations - 1) alias_->Clear();
    }
开发者ID:fulQuan,项目名称:LightLDA_Inference,代码行数:69,代码来源:trainer.cpp


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