5#include "flutter/fml/message_loop_task_queues.h"
12#include "flutter/benchmarking/benchmarking.h"
13#include "flutter/fml/synchronization/count_down_latch.h"
19 while (
state.KeepRunning()) {
22 const int num_task_queues = 10;
23 const int num_tasks_per_queue = 100;
26 for (
int i = 0;
i < num_task_queues;
i++) {
27 task_queue->CreateTaskQueue();
30 std::vector<std::thread> threads;
35 threads.reserve(num_task_queues);
36 for (
int i = 0;
i < num_task_queues;
i++) {
37 threads.emplace_back([task_runner_id =
i, &task_queue, past, &tasks_done,
38 &tasks_registered]() {
39 for (
int j = 0; j < num_tasks_per_queue; j++) {
40 task_queue->RegisterTask(
TaskQueueId(task_runner_id), [] {}, past);
43 tasks_registered.
Wait();
45 int num_invocations = 0;
48 task_queue->GetNextTaskToRun(
TaskQueueId(task_runner_id), now);
54 assert(num_invocations == num_tasks_per_queue);
61 for (
auto& thread : threads) {
static MessageLoopTaskQueues * GetInstance()
static void BM_RegisterAndGetTasks(benchmark::State &state)
BENCHMARK(BM_RegisterAndGetTasks)
std::function< void()> closure