diff --git a/shell/common/shell_benchmarks.cc b/shell/common/shell_benchmarks.cc index 9d3a1a36f9c9a4f0dee4ef69284f5ee89e3d63de..2232997a38b236d18edab89cb962754b2df23b7d 100644 --- a/shell/common/shell_benchmarks.cc +++ b/shell/common/shell_benchmarks.cc @@ -66,6 +66,17 @@ static void StartupAndShutdownShell(benchmark::State& state, FML_CHECK(shell); + { + // The ui thread could be busy processing tasks after shell created, e.g., + // default font manager setup. The measurement of shell shutdown should be + // considered after those ui tasks have been done. + benchmarking::ScopedPauseTiming pause(state, true); + fml::AutoResetWaitableEvent latch; + fml::TaskRunner::RunNowOrPostTask(thread_host->ui_thread->GetTaskRunner(), + [&latch]() { latch.Signal(); }); + latch.Wait(); + } + { benchmarking::ScopedPauseTiming pause(state, !measure_shutdown); // Shutdown must occur synchronously on the platform thread.