Skip to content

Commit

Permalink
Issue thegrandpoobah#14: Display total elapsed time at the end of the…
Browse files Browse the repository at this point in the history
… computation.
  • Loading branch information
thegrandpoobah committed Feb 25, 2012
1 parent 69a9707 commit 74cfaf1
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions voronoi/voronoi.cpp
Expand Up @@ -144,6 +144,8 @@ int main( int argc, char *argv[] ) {
using std::min;
using boost::timer;

timer total_profiler;

auto_ptr<Voronoi::StipplingParameters> parameters;

stippler_lib_init();
Expand Down Expand Up @@ -181,16 +183,13 @@ int main( int argc, char *argv[] ) {

int iteration = 0;
float t = parameters->threshold + 1.0f;
timer iteration_profiler;

do {
timer profiler;
iteration_profiler.restart();

stippler_distribute(stippler);

if ( parameters->createLogs ) {
log << "Iteration " << (++iteration) << " completed in " << profiler.elapsed() << " seconds." << endl;
cout << "Iteration " << iteration << " completed in " << profiler.elapsed() << " seconds." << endl;
}

t = stippler_getAverageDisplacement( stippler );

if ( parameters->createLogs ) {
Expand All @@ -199,6 +198,11 @@ int main( int argc, char *argv[] ) {
}

cout << setiosflags(ios::fixed) << setprecision(2) << min((parameters->threshold / t * 100), 100.0f) << "% Complete" << endl;

if ( parameters->createLogs ) {
log << "Iteration " << (++iteration) << " completed in " << iteration_profiler.elapsed() << " seconds." << endl;
cout << "Iteration " << iteration << " completed in " << iteration_profiler.elapsed() << " seconds." << endl;
}
} while ( t > parameters->threshold );

// render final result to SVG
Expand All @@ -216,5 +220,7 @@ int main( int argc, char *argv[] ) {

destroy_stippler( stippler );

cout << "Completed in " << total_profiler.elapsed() << " seconds." << endl;

return 0;
}

0 comments on commit 74cfaf1

Please sign in to comment.