diff options
author | Carlo Zancanaro <carlo@carlo-laptop> | 2012-10-27 13:38:24 +1100 |
---|---|---|
committer | Carlo Zancanaro <carlo@carlo-laptop> | 2012-10-27 13:38:24 +1100 |
commit | ff2030f3a19926334fbe3a043c5f88622c17c2f8 (patch) | |
tree | 2d2f74dd31e1a5e6698846852e8ab3c47e8bd6a5 | |
parent | 97a9582ec8928624cd78146ae060aadfd92a9b22 (diff) |
Output some timing information to stderr.
-rw-r--r-- | impl/main.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
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 <ctime> + extern "C" { #include "parser/EquationSystemParser.h" #include "parser/EquationSystemLexer.h" @@ -144,6 +146,23 @@ int main (int argc, char* argv[]) { DynamicVariableAssignment<ZBar> 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<ZBar>& 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<ZBar>& 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<ZBar>& 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); |