• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2025 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//build/config/components/ets_frontend/es2abc_config.gni")
15import("//build/ohos.gni")
16import("//test/testfwk/arkxtest/arkxtest_config.gni")
17
18config("perftest_common_configs") {
19  cflags = [
20    "-Wfloat-equal",
21    "-Wformat=2",
22    "-Wshadow",
23  ]
24}
25common_external_deps = [
26  "c_utils:utils",
27  "hilog:libhilog",
28  "json:nlohmann_json_static",
29]
30
31ohos_static_library("perftest_core") {
32  use_exceptions = true
33  configs = [ ":perftest_common_configs" ]
34  sources = [
35    "./core/src/frontend_api_handler.cpp",
36    "./core/src/perf_test.cpp",
37    "./core/src/perf_test_strategy.cpp",
38    "./collection/src/data_collection.cpp",
39    "./collection/src/duration_collection.cpp",
40    "./collection/src/cpu_collection.cpp",
41    "./collection/src/memory_collection.cpp",
42    "./collection/src/app_start_time_collection.cpp",
43    "./collection/src/page_switch_time_collection.cpp",
44    "./collection/src/list_swipe_fps_collection.cpp",
45  ]
46  include_dirs = [
47    "./connection/include",
48    "./core/include",
49    "./collection/include",
50  ]
51  defines = [
52    "__OHOS__=1",
53    "LOG_TAG=\"PerfTest_Server\"",
54  ]
55  deps = [ "../testserver/src:test_server_client" ]
56  external_deps = [
57    "ability_base:want",
58    "common_event_service:cesfwk_innerkits",
59    "ipc:ipc_core",
60    "hiview:libucollection_utility",
61    "hisysevent:libhisysevent",
62    "hisysevent:libhisyseventmanager",
63  ]
64  external_deps += common_external_deps
65  subsystem_name = "testfwk"
66  part_name = "arkxtest"
67}
68
69ohos_static_library("perftest_ipc") {
70  configs = [ ":perftest_common_configs" ]
71  sources = [
72    "./connection/src/api_caller_client.cpp",
73    "./connection/src/api_caller_server.cpp",
74    "./connection/src/ipc_transactor.cpp",
75  ]
76  include_dirs = [
77    "./connection/include",
78    "./core/include",
79  ]
80  deps = [ "../testserver/src:test_server_client" ]
81  external_deps = [
82    "ability_base:want",
83    "common_event_service:cesfwk_innerkits",
84    "ipc:ipc_core",
85    "samgr:samgr_proxy",
86  ]
87  external_deps += common_external_deps
88  subsystem_name = "testfwk"
89  part_name = "arkxtest"
90  defines = [
91    "__OHOS__=1",
92    "LOG_TAG=\"PerfTest_Conn\"",
93  ]
94}
95
96ohos_executable("perftest_server") {
97  configs = [ ":perftest_common_configs" ]
98  sources = [
99    "./core/src/start_daemon.cpp",
100  ]
101  include_dirs = [
102    "./connection/include",
103    "./core/include",
104  ]
105  deps = [
106    ":perftest_ipc",
107    ":perftest_core",
108  ]
109  external_deps = [
110    "ability_base:want",
111    "common_event_service:cesfwk_innerkits",
112  ]
113  external_deps += common_external_deps
114  subsystem_name = "testfwk"
115  part_name = "arkxtest"
116  output_name = "perftest"
117  if (arkxtest_product_feature == "watch") {
118    install_enable = false
119  }
120}
121
122es2abc_gen_abc("gen_perftest_exporter_abc") {
123  src_js = rebase_path("./napi/src/perftest_exporter.js")
124  dst_file = rebase_path(target_out_dir + "/perftest_exporter.abc")
125  in_puts = [ "./napi/src/perftest_exporter.js" ]
126  out_puts = [ target_out_dir + "/perftest_exporter.abc" ]
127  extra_args = [ "--module" ]
128}
129
130gen_js_obj("perftest_exporter_js") {
131  input = "./napi/src/perftest_exporter.js"
132  output = target_out_dir + "/perftest_exporter.o"
133}
134
135gen_js_obj("perftest_exporter_abc") {
136  input = get_label_info(":gen_exporter_abc", "target_out_dir") +
137          "/perftest_exporter.abc"
138  output = target_out_dir + "/perftest_exporter_abc.o"
139  dep = ":gen_perftest_exporter_abc"
140}
141
142ohos_shared_library("perftest_client") {
143  configs = [ ":perftest_common_configs" ]
144  sources = [
145    "./napi/src/perftest_napi.cpp",
146    "./napi/src/callback_code_napi.cpp",
147  ]
148  include_dirs = [
149    "./core/include",
150    "./connection/include",
151    "./napi/include",
152  ]
153  deps = [
154    ":perftest_exporter_abc",
155    ":perftest_exporter_js",
156    ":perftest_ipc",
157  ]
158  subsystem_name = "testfwk"
159  part_name = "arkxtest"
160  output_name = "perftest"
161  external_deps = common_external_deps
162  external_deps += [
163    "ability_base:want",
164    "common_event_service:cesfwk_innerkits",
165    "libuv:uv",
166    "napi:ace_napi",
167  ]
168  relative_install_dir = "module/test"
169  defines = [
170    "__OHOS__=1",
171    "LOG_TAG=\"PerfTest_Client\"",
172  ]
173  if (arkxtest_product_feature == "watch") {
174    install_enable = false
175  }
176}
177
178group("perftestkit") {
179  deps = [
180    ":perftest_client",
181    ":perftest_server",
182  ]
183}
184
185ohos_unittest("perftest_unittest") {
186  sources = [
187    "test/unittest/data_collection_test.cpp",
188    "test/unittest/ipc_transactor_test.cpp",
189    "test/unittest/frontend_api_handler_test.cpp",
190    "test/unittest/perf_test_test.cpp",
191  ]
192  deps = [
193    ":perftest_core",
194    ":perftest_ipc",
195    ":perftest_client",
196  ]
197  include_dirs = [
198    "./core/include",
199    "./connection/include",
200    "./napi/include",
201    "./collection/include",
202  ]
203  external_deps = [
204    "ability_base:want",
205    "common_event_service:cesfwk_innerkits",
206    "googletest:gmock_main",
207    "googletest:gtest_main",
208    "hilog:libhilog",
209    "hisysevent:libhisysevent",
210    "hisysevent:libhisyseventmanager",
211    "json:nlohmann_json_static",
212  ]
213  ldflags = [ "--coverage" ]
214  cflags = [ "--coverage" ]
215  cflags_cc = [ "--coverage" ]
216  use_exceptions = true
217  module_out_path = "arkxtest/perftest"
218  testonly = true
219  subsystem_name = "testfwk"
220  part_name = "arkxtest"
221}
222