Flutter Engine
The Flutter Engine
Functions
fml::benchmarking Namespace Reference

Functions

static void BM_RegisterAndGetTasks (benchmark::State &state)
 
 BENCHMARK (BM_RegisterAndGetTasks)
 

Function Documentation

◆ BENCHMARK()

fml::benchmarking::BENCHMARK ( BM_RegisterAndGetTasks  )

◆ BM_RegisterAndGetTasks()

static void fml::benchmarking::BM_RegisterAndGetTasks ( benchmark::State &  state)
static

Definition at line 18 of file message_loop_task_queues_benchmark.cc.

18 { // NOLINT
19 while (state.KeepRunning()) {
21
22 const int num_task_queues = 10;
23 const int num_tasks_per_queue = 100;
25
26 for (int i = 0; i < num_task_queues; i++) {
27 task_queue->CreateTaskQueue();
28 }
29
30 std::vector<std::thread> threads;
31
32 CountDownLatch tasks_registered(num_task_queues);
33 CountDownLatch tasks_done(num_task_queues);
34
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);
41 }
42 tasks_registered.CountDown();
43 tasks_registered.Wait();
44 const auto now = fml::TimePoint::Now();
45 int num_invocations = 0;
46 for (;;) {
47 fml::closure invocation =
48 task_queue->GetNextTaskToRun(TaskQueueId(task_runner_id), now);
49 if (!invocation) {
50 break;
51 }
52 num_invocations++;
53 }
54 assert(num_invocations == num_tasks_per_queue);
55 tasks_done.CountDown();
56 });
57 }
58
59 tasks_done.Wait();
60
61 for (auto& thread : threads) {
62 thread.join();
63 }
64 }
65}
static MessageLoopTaskQueues * GetInstance()
static TimePoint Now()
Definition: time_point.cc:49
AtkStateType state
std::function< void()> closure
Definition: closure.h:14