@@ -62,7 +62,7 @@ namespace onnx_mlir {
62
62
// Values to report the current phase of compilation.
63
63
// Increase TOTAL_COMPILE_PHASE when having more phases.
64
64
uint64_t CURRENT_COMPILE_PHASE = 1 ;
65
- uint64_t TOTAL_COMPILE_PHASE = 5 ;
65
+ uint64_t TOTAL_COMPILE_PHASE = 6 ;
66
66
67
67
// Make a function that forces preserving all files using the runtime arguments
68
68
// and/or the overridePreserveFiles enum.
@@ -170,24 +170,37 @@ int Command::exec(std::string wdir) const {
170
170
}
171
171
172
172
void showCompilePhase (std::string msg) {
173
- time_t rawtime ;
174
- struct tm *timeinfo ;
173
+ time_t rawTime ;
174
+ struct tm *timeInfo ;
175
175
char buffer[80 ];
176
+ // Remember first time.
177
+ static time_t firstRawTime;
178
+ static bool hasFirstRawTime = false ;
176
179
177
180
// Get current date.
178
- time (&rawtime );
179
- timeinfo = localtime (&rawtime );
180
- strftime (buffer, 80 , " %c" , timeinfo );
181
+ time (&rawTime );
182
+ timeInfo = localtime (&rawTime );
183
+ strftime (buffer, 80 , " %c" , timeInfo );
181
184
std::string currentTime (buffer);
182
185
186
+ // Compute time difference in seconds.
187
+ int diff = 0 ;
188
+ if (hasFirstRawTime) {
189
+ diff = difftime (rawTime, firstRawTime);
190
+ } else {
191
+ firstRawTime = rawTime;
192
+ hasFirstRawTime = true ;
193
+ }
183
194
llvm::outs () << " [" << CURRENT_COMPILE_PHASE++ << " /" << TOTAL_COMPILE_PHASE
184
- << " ] " << currentTime << " " << msg << " \n " ;
195
+ << " ] " << currentTime << " ( " << diff << " s) " << msg << " \n " ;
185
196
// Flush so that if there are errors, we know where it came from.
186
197
llvm::outs ().flush ();
187
198
188
199
// Reset current phase.
189
- if (CURRENT_COMPILE_PHASE > TOTAL_COMPILE_PHASE)
200
+ if (CURRENT_COMPILE_PHASE > TOTAL_COMPILE_PHASE) {
190
201
CURRENT_COMPILE_PHASE = 1 ;
202
+ hasFirstRawTime = false ;
203
+ }
191
204
}
192
205
193
206
} // namespace onnx_mlir
@@ -813,6 +826,8 @@ static int emitOutputFiles(std::string outputNameNoExt,
813
826
}
814
827
}
815
828
}
829
+ showCompilePhase (" Compilation completed" );
830
+
816
831
return CompilerSuccess;
817
832
} // end anonymous namespace
818
833
0 commit comments