-int llvmc::Action::Execute() const {
- if (DryRun || VerboseMode) {
- errs() << Command_ << " ";
- std::for_each(Args_.begin(), Args_.end(), print_string);
- errs() << '\n';
+namespace llvmc {
+ void AppendToGlobalTimeLog (const std::string& cmd, double time);
+}
+
+int llvmc::Action::Execute () const {
+ if (DryRun || VerboseMode)
+ PrintCommand(Command_, Args_);
+
+ if (!DryRun) {
+ if (Time) {
+ sys::TimeValue now = sys::TimeValue::now();
+ int ret = ExecuteProgram(Command_, Args_);
+ sys::TimeValue now2 = sys::TimeValue::now();
+ now2 -= now;
+ double elapsed = now2.seconds() + now2.microseconds() / 1000000.0;
+ AppendToGlobalTimeLog(Command_, elapsed);
+
+ return ret;
+ }
+ else {
+ return ExecuteProgram(Command_, Args_);
+ }