30
30
#include < executorch/runtime/executor/method.h>
31
31
#include < executorch/runtime/executor/program.h>
32
32
#include < executorch/runtime/platform/log.h>
33
+ #include < executorch/runtime/platform/platform.h>
33
34
#include < executorch/runtime/platform/runtime.h>
34
35
#ifdef ET_EVENT_TRACER_ENABLED
35
36
#include < executorch/devtools/etdump/etdump_flatcc.h>
@@ -249,6 +250,7 @@ int main(int argc, char** argv) {
249
250
(uint32_t )method.error ());
250
251
ET_LOG (Info, " Method loaded." );
251
252
253
+ et_timestamp_t time_spent_executing = 0 ;
252
254
// Run the model.
253
255
for (uint32_t i = 0 ; i < FLAGS_num_executions; i++) {
254
256
ET_LOG (Debug, " Preparing inputs." );
@@ -267,17 +269,24 @@ int main(int argc, char** argv) {
267
269
(uint32_t )inputs.error ());
268
270
ET_LOG (Debug, " Inputs prepared." );
269
271
272
+ const et_timestamp_t before_execute = et_pal_current_ticks ();
270
273
Error status = method->execute ();
274
+ const et_timestamp_t after_execute = et_pal_current_ticks ();
275
+ time_spent_executing += after_execute - before_execute;
271
276
ET_CHECK_MSG (
272
277
status == Error::Ok,
273
278
" Execution of method %s failed with status 0x%" PRIx32,
274
279
method_name,
275
280
(uint32_t )status);
276
281
}
282
+ const auto tick_ratio = et_pal_ticks_to_ns_multiplier ();
283
+ constexpr auto NANOSECONDS_PER_MILLISECOND = 1000000 ;
277
284
ET_LOG (
278
285
Info,
279
- " Model executed successfully %" PRIu32 " time(s)." ,
280
- FLAGS_num_executions);
286
+ " Model executed successfully %" PRIu32 " time(s) in %f ms." ,
287
+ FLAGS_num_executions,
288
+ static_cast <double >(time_spent_executing) * tick_ratio.numerator /
289
+ tick_ratio.denominator / NANOSECONDS_PER_MILLISECOND);
281
290
282
291
// Print the outputs.
283
292
std::vector<EValue> outputs (method->outputs_size ());
0 commit comments