From 9a153a6506cb6a70da655176daaf58a36261b595 Mon Sep 17 00:00:00 2001 From: Virendra Singh Date: Wed, 25 Feb 2015 08:36:58 +0530 Subject: [PATCH] Time measurement Used c++11 chrono class to measure elapsed time. --- tools/vhacd/src/VHACDUtil.h | 2 +- tools/vhacd/src/main.cpp | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/vhacd/src/VHACDUtil.h b/tools/vhacd/src/VHACDUtil.h index aaabcdf904..036d4ce526 100644 --- a/tools/vhacd/src/VHACDUtil.h +++ b/tools/vhacd/src/VHACDUtil.h @@ -16,7 +16,7 @@ #include #include #include - +#include //c++11 feature #include #include #include diff --git a/tools/vhacd/src/main.cpp b/tools/vhacd/src/main.cpp index a80a57bb3e..31866a7cfc 100644 --- a/tools/vhacd/src/main.cpp +++ b/tools/vhacd/src/main.cpp @@ -27,9 +27,14 @@ int main(int argc, char * argv[]){ vhacd::ComputeResults results; // results after computing vhacd VHACD::IVHACD::Parameters params; vhacd::ProgressCallback pCallBack; - - QString fname = "F:/models/ship/Sample_Ship.fbx"; + string filename(argv[1]); + if (filename.empty()){ + cout << "please provide a FBX file as argument\n "; + return 1; + } + + QString fname = QString::fromStdString(filename); //set parameters for V-HACD params.m_callback = &pCallBack; //progress callback @@ -43,15 +48,23 @@ int main(int argc, char * argv[]){ params.m_minVolumePerCH = 0.0001; // controls the adaptive sampling of the generated convex - hulls // load the mesh + + auto begin = std::chrono::high_resolution_clock::now(); if (!vUtil.loadFBX(fname, &fbx)){ cout << "Error in opening FBX file...."; return 1; } + auto end = std::chrono::high_resolution_clock::now(); + auto loadDuration = std::chrono::duration_cast(end - begin).count(); + //perform vhacd computation + begin = std::chrono::high_resolution_clock::now(); if (!vUtil.computeVHACD(&fbx, params, &results)){ cout << "Compute Failed..."; return 1; } + end = std::chrono::high_resolution_clock::now(); + auto computeDuration = std::chrono::duration_cast(end - begin).count(); int totalVertices = 0; for (int i = 0; i < fbx.meshCount; i++){ @@ -75,6 +88,8 @@ int main(int argc, char * argv[]){ cout << "Total vertices : " << totalVertices << endl; cout << "Total Triangles : " << totalTriangles << endl; cout << "Total Convex Hulls : " << totalHulls << endl; + cout << "Total FBX load time: " << (double)loadDuration / 1000000000.00 << " seconds" << endl; + cout << "V-HACD Compute time: " << (double)computeDuration / 1000000000.00 << " seconds" << endl; cout << endl << "Summary per convex hull ........................" << endl <