5#include "flutter/benchmarking/benchmarking.h"
6#include "flutter/common/settings.h"
7#include "flutter/lib/ui/volatile_path_tracker.h"
8#include "flutter/lib/ui/window/platform_message_response_dart.h"
9#include "flutter/runtime/dart_vm_lifecycle.h"
10#include "flutter/shell/common/thread_host.h"
11#include "flutter/testing/dart_isolate_runner.h"
12#include "flutter/testing/fixture_test.h"
19 void TestBody()
override {};
25 ThreadHost::Type::kIo | ThreadHost::Type::kUi));
37 while (
state.KeepRunning()) {
39 bool successful = isolate->RunInIsolateScope([&]() ->
bool {
41 std::vector<uint8_t>
data(3 << 20, 0);
42 std::unique_ptr<fml::Mapping> mapping =
43 std::make_unique<fml::DataMapping>(
data);
49 auto message = fml::MakeRefCounted<PlatformMessageResponseDart>(
51 thread_host.
ui_thread->GetTaskRunner(),
"");
53 message->Complete(std::move(mapping));
63 std::promise<bool> completed;
65 [&completed] { completed.set_value(
true); });
66 completed.get_future().wait();
73 ThreadHost::Type::kIo | ThreadHost::Type::kUi));
81 while (
state.KeepRunning()) {
82 std::vector<std::shared_ptr<VolatilePathTracker::TrackedPath>> paths;
83 constexpr int path_count = 1000;
84 for (
int i = 0;
i < path_count;
i++) {
85 auto path = std::make_shared<VolatilePathTracker::TrackedPath>();
87 path->path.setIsVolatile(
true);
88 paths.push_back(std::move(
path));
93 for (
const auto&
path : paths) {
103 for (
int i = 0;
i < path_count - 10; ++
i) {
116 ->Unit(benchmark::kMicrosecond);
static DartVMRef Create(const Settings &settings, fml::RefPtr< const DartSnapshot > vm_snapshot=nullptr, fml::RefPtr< const DartSnapshot > isolate_snapshot=nullptr)
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
void Track(const std::shared_ptr< TrackedPath > &path)
virtual Settings CreateSettingsForFixture()
virtual void PostTask(const fml::closure &task) override
struct _Dart_Handle * Dart_Handle
DART_EXPORT Dart_Handle Dart_NewStringFromCString(const char *str)
DART_EXPORT DART_WARN_UNUSED_RESULT Dart_Handle Dart_GetField(Dart_Handle container, Dart_Handle name)
DART_EXPORT Dart_Handle Dart_RootLibrary(void)
@ kRaster
Suitable for thread which raster data.
#define FML_CHECK(condition)
std::string GetDefaultKernelFilePath()
Returns the default path to kernel_blob.bin. This file is within the directory returned by GetFixture...
std::unique_ptr< AutoIsolateShutdown > RunDartCodeInIsolate(DartVMRef &vm_ref, const Settings &settings, const TaskRunners &task_runners, std::string entrypoint, const std::vector< std::string > &args, const std::string &kernel_file_path, fml::WeakPtr< IOManager > io_manager, std::shared_ptr< VolatilePathTracker > volatile_path_tracker, std::unique_ptr< PlatformConfiguration > platform_configuration)
BENCHMARK(BM_PathVolatilityTracker) -> Unit(benchmark::kMillisecond)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
static void BM_PathVolatilityTracker(benchmark::State &state)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
static void BM_PlatformMessageResponseDartComplete(benchmark::State &state)
std::function< void()> closure
The collection of all the threads used by the engine.
std::unique_ptr< fml::Thread > io_thread
std::unique_ptr< fml::Thread > platform_thread
std::unique_ptr< fml::Thread > raster_thread
std::unique_ptr< fml::Thread > ui_thread