本文整理汇总了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();
示例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();
示例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());
}
}
示例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();
}