From ff2030f3a19926334fbe3a043c5f88622c17c2f8 Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Sat, 27 Oct 2012 13:38:24 +1100 Subject: Output some timing information to stderr. --- impl/main.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/impl/main.cpp b/impl/main.cpp index b547c48..b83894d 100644 --- a/impl/main.cpp +++ b/impl/main.cpp @@ -9,6 +9,8 @@ #include "MaxStrategy.hpp" #include "VariableAssignment.hpp" +#include + extern "C" { #include "parser/EquationSystemParser.h" #include "parser/EquationSystemLexer.h" @@ -144,6 +146,23 @@ int main (int argc, char* argv[]) { DynamicVariableAssignment rho(system, strategy); strategy.setRho(rho); + timespec start, finish; + clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start); + if (variables.size() > 0) { + for (unsigned int i = 0, size = system.variableCount(); i < size; ++i) { + Variable& var = system.variable(i); + if (variables.find(var.name()) != variables.end()) { + rho[var]; + } + } + } else { + for (unsigned int i = 0, size = system.variableCount(); i < size; ++i) { + Variable& var = system.variable(i); + rho[var]; + } + } + clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &finish); + if (variables.size() > 0) { for (unsigned int i = 0, size = system.variableCount(); i < size; ++i) { Variable& var = system.variable(i); @@ -158,6 +177,17 @@ int main (int argc, char* argv[]) { } } + timespec temp; + if ((finish.tv_nsec-start.tv_nsec)<0) { + temp.tv_sec = finish.tv_sec-start.tv_sec-1; + temp.tv_nsec = 1000000000+finish.tv_nsec-start.tv_nsec; + } else { + temp.tv_sec = finish.tv_sec-start.tv_sec; + temp.tv_nsec = finish.tv_nsec-start.tv_nsec; + } + cerr << "Time taken: " << temp.tv_sec << " seconds and " << temp.tv_nsec << " nanoseconds." << endl; + + parser -> free(parser); tokens -> free(tokens); lex -> free(lex); -- cgit v1.2.3