diff --git a/arkoala-arkts/arkui/src/ani/arkts/ArkUIAniModule.ts b/arkoala-arkts/arkui/src/ani/arkts/ArkUIAniModule.ts index 2b9deebbba26d8f29c11bbd8209d2f40b43f0c1b..24410a75121cf9692113bf0beaa739e4bee3b971 100644 --- a/arkoala-arkts/arkui/src/ani/arkts/ArkUIAniModule.ts +++ b/arkoala-arkts/arkui/src/ani/arkts/ArkUIAniModule.ts @@ -237,4 +237,7 @@ export class ArkUIAniModule { native static _ScrollableTargetInfoAccessorWithId(input: KPointer, id: string): void native static _ScrollableTargetInfoAccessorWithPointer(input: KPointer, pointer: KPointer): void native static _TransferScrollableTargetInfoPointer(input: KPointer): KPointer + + native static _StartProfiler(asptFileName: string, interva: KInt): void + native static _StopProfiler(): void } diff --git a/arkoala-arkts/arkui/src/ani/native/BUILD.gn b/arkoala-arkts/arkui/src/ani/native/BUILD.gn index ded9ab40dca7c27832bdc2ee5a342a4e6495fa65..3054faf130b8f500056204cbb0d03ccb906b75f3 100644 --- a/arkoala-arkts/arkui/src/ani/native/BUILD.gn +++ b/arkoala-arkts/arkui/src/ani/native/BUILD.gn @@ -44,6 +44,7 @@ ohos_shared_library("arkoala_native_ani") { "module.cpp", "shape/shape_module_methods.cpp", "styled_string/styled_string_module.cpp", + "utils/ani_profiler.cpp", "utils/ani_utils.cpp", "utils/convert_utils.cpp", "video/video_module_methods.cpp", @@ -67,6 +68,7 @@ ohos_shared_library("arkoala_native_ani") { "udmf:libudmf", "udmf:udmf_client", "udmf:udmf_taihe_native", + "runtime_core:libarkruntime", ] configs = [ "$ace_root:ace_config" ] diff --git a/arkoala-arkts/arkui/src/ani/native/module.cpp b/arkoala-arkts/arkui/src/ani/native/module.cpp index 6487c998a107b772164e305185fdb276a0bfe092..b1db8311d1a35f02aa55622d2299255438626b11 100644 --- a/arkoala-arkts/arkui/src/ani/native/module.cpp +++ b/arkoala-arkts/arkui/src/ani/native/module.cpp @@ -31,6 +31,7 @@ #include "list/list_children_main_size_module.h" #include "load.h" #include "log/log.h" +#include "utils/ani_profiler.h" #include "utils/convert_utils.h" #include "water_flow/waterFlowSection_module.h" #include "interop/interop_module.h" @@ -760,6 +761,16 @@ ANI_EXPORT ani_status ANI_Constructor(ani_vm* vm, uint32_t* result) "_ImageBitmap_Construct1", "C{@ohos.multimedia.image.image.PixelMap}i:l", reinterpret_cast(OHOS::Ace::Ani::CanvasModule::ImageBitmapConstruct1) + }, + ani_native_function { + "_StartProfiler", + nullptr, + reinterpret_cast(OHOS::Ace::Ani::AniProfiler::StartProfiler) + }, + ani_native_function { + "_StopProfiler", + nullptr, + reinterpret_cast(OHOS::Ace::Ani::AniProfiler::StopProfiler) } }; diff --git a/arkoala-arkts/arkui/src/ani/native/utils/ani_profiler.cpp b/arkoala-arkts/arkui/src/ani/native/utils/ani_profiler.cpp new file mode 100644 index 0000000000000000000000000000000000000000..039c52ef2410bab68f20f64289ee81f9349fe88b --- /dev/null +++ b/arkoala-arkts/arkui/src/ani/native/utils/ani_profiler.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ani_profiler.h" + +#include "ani_utils.h" +#include "load.h" + +extern "C" int StartSamplingProfiler(const char* asptFileName, int interva); +extern "C" int StopSamplingProfiler(); + +namespace OHOS::Ace::Ani { + +void AniProfiler::StartProfiler(ani_env* env, [[maybe_unused]] ani_object aniClass, + ani_string asptFileName, ani_int interva) +{ + auto fileName = AniUtils::ANIStringToStdString(env, asptFileName); + StartSamplingProfiler(fileName.c_str(), static_cast(interva)); +} + +void AniProfiler::StopProfiler(ani_env* env, [[maybe_unused]] ani_object aniClass) +{ + StopSamplingProfiler(); +} + +} // namespace OHOS::Ace::Ani diff --git a/arkoala-arkts/arkui/src/ani/native/utils/ani_profiler.h b/arkoala-arkts/arkui/src/ani/native/utils/ani_profiler.h new file mode 100644 index 0000000000000000000000000000000000000000..8c7dd7048144018430cd98af95b57c109a98b794 --- /dev/null +++ b/arkoala-arkts/arkui/src/ani/native/utils/ani_profiler.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef KOALA_PROJECTS_ARKOALA_ARKTS_ARKUI_OHOS_ANI_NATIVE_ANI_PROFILER +#define KOALA_PROJECTS_ARKOALA_ARKTS_ARKUI_OHOS_ANI_NATIVE_ANI_PROFILER + +#include "ani.h" + +namespace OHOS::Ace::Ani { + +class AniProfiler { +public: + static void StartProfiler(ani_env* env, [[maybe_unused]] ani_object aniClass, + ani_string asptFileName, ani_int interva); + static void StopProfiler(ani_env* env, [[maybe_unused]] ani_object aniClass); +}; + +} // namespace OHOS::Ace::Ani + +#endif // KOALA_PROJECTS_ARKOALA_ARKTS_ARKUI_OHOS_ANI_NATIVE_ANI_PROFILER diff --git a/arkoala-arkts/arkui/src/base/ArkSampler.ets b/arkoala-arkts/arkui/src/base/ArkSampler.ets new file mode 100644 index 0000000000000000000000000000000000000000..35e748302161843e9ae351bc90d9d8ee1028bbfe --- /dev/null +++ b/arkoala-arkts/arkui/src/base/ArkSampler.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { KInt } from "@koalaui/interop" + +import { ArkUIAniModule } from "../ani/arkts/ArkUIAniModule" + +export class ArkSampler { + + static startProfiler(asptFileName: string, interva: KInt) { + ArkUIAniModule._StartProfiler(asptFileName, interva) + } + + static stopProfiler() { + ArkUIAniModule._StopProfiler() + } + +} diff --git a/arkoala-arkts/arkui_components.gni b/arkoala-arkts/arkui_components.gni index 0a2a23114228434fbfa3cad22e78ace726a5a062..d74258261d68997fd5cab2187c87b7b08d62fb21 100644 --- a/arkoala-arkts/arkui_components.gni +++ b/arkoala-arkts/arkui_components.gni @@ -324,6 +324,7 @@ arkui_files = [ "arkui/src/ani/arkts/index.ts", "arkui/src/ani/arkts/ui_extension/ArkUIAniUiextensionLoadLibraryHelp.ts", "arkui/src/ani/arkts/ui_extension/ArkUIAniUiextensionModal.ts", + "arkui/src/base/ArkSampler.ets", "arkui/src/component/builder.ets", "arkui/src/component/canvas.ets", "arkui/src/component/common.ets",