From 73e45012acd33cfbf9635e1b7c2c9619273cb862 Mon Sep 17 00:00:00 2001 From: Sreekanth Arikatla <sreekanth.arikatla@kitware.com> Date: Wed, 30 Aug 2017 11:49:09 -0400 Subject: [PATCH] ENH: Add utility to print the updates per sec for a given scene --- Source/Core/imstkAPIUtilities.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Source/Core/imstkAPIUtilities.h b/Source/Core/imstkAPIUtilities.h index 890e9cda5..553266fb9 100644 --- a/Source/Core/imstkAPIUtilities.h +++ b/Source/Core/imstkAPIUtilities.h @@ -212,6 +212,35 @@ createNonLinearSystem(std::shared_ptr<imstk::FEMDeformableBodyModel> dynaModel) return nlSystem; } + +/// +/// \brief Print number of updates for second for a given scene +/// +void +printUPS(std::shared_ptr<SceneManager> sceneManager, std::shared_ptr<UPSCounter> ups) +{ + sceneManager->setPreInitCallback([](Module* module) + { + LOG(INFO) << "-- Pre initialization of " << module->getName() << " module"; + }); + + sceneManager->setPreUpdateCallback([&ups](Module* module) + { + ups->setStartPointOfUpdate(); + }); + + sceneManager->setPostUpdateCallback([&ups](Module* module) + { + ups->setEndPointOfUpdate(); + std::cout << "\r-- " << module->getName() << " running at " + << ups->getUPS() << " ups " << std::flush; + }); + + sceneManager->setPostCleanUpCallback([](Module* module) + { + LOG(INFO) << "\n-- Post cleanup of " << module->getName() << " module"; + }); +} } //apiutils } // imstk -- GitLab