1/* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#include "performance_test.h" 17 18#include <sys/time.h> 19 20#include "test_common.h" 21 22namespace Contacts { 23namespace Test { 24PerformanceTest::PerformanceTest() 25{ 26} 27 28PerformanceTest::~PerformanceTest() 29{ 30} 31 32int64_t PerformanceTest::GetCurrentTime() 33{ 34 int subtle = 1000000; 35 struct timeval time; 36 gettimeofday(&time, nullptr); 37 return (time.tv_sec * subtle + time.tv_usec); 38} 39 40int PerformanceTest::CalcTime(int64_t startTime, int64_t endTime) 41{ 42 return (int)(endTime - startTime); 43} 44 45void PerformanceTest::DeleteContact() 46{ 47 OHOS::DataShare::DataSharePredicates predicates; 48 OHOS::Uri uriRawContact(ContactsUri::RAW_CONTACT); 49 predicates.NotEqualTo("id", "0"); 50 predicates.And(); 51 predicates.EqualTo("is_deleted", "0"); 52 contactsDataAbility.Delete(uriRawContact, predicates); 53 int count = 0; 54 int deleteCount = 9999; 55 std::vector<std::string> columns; 56 OHOS::Uri uriRawContactComplete(ContactsUri::DELETED_RAW_CONTACT); 57 while (count < deleteCount) { 58 int time = Time::SLEEP_TIME_MERGE_DELETE; 59 std::chrono::milliseconds dura(time); 60 std::this_thread::sleep_for(dura); 61 OHOS::DataShare::DataSharePredicates predicates2; 62 std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = 63 contactsDataAbility.Query(uriRawContactComplete, predicates2, columns); 64 resultSet->GetRowCount(count); 65 resultSet->Close(); 66 } 67 int time = Time::SLEEP_TIME_MERGE_DELETE; 68 std::chrono::milliseconds dura(time); 69 std::this_thread::sleep_for(dura); 70 OHOS::DataShare::DataSharePredicates predicates3; 71 predicates3.NotEqualTo("id", "0"); 72 contactsDataAbility.Delete(uriRawContactComplete, predicates3); 73} 74 75/* 76 * @tc.number raw_contact_insert_performance_test_900 77 * @tc.name raw_contact performance testing add 10000 78 * @tc.desc add 10000 79 * @tc.level Level1 80 * @tc.size MediumTest 81 * @tc.type Function 82 */ 83HWTEST_F(PerformanceTest, raw_contact_insert_performance_test_900, testing::ext::TestSize.Level1) 84{ 85 HILOG_INFO("--- raw_contact_insert_performance_test_900 is starting! ---"); 86 OHOS::Uri uriRawContact(ContactsUri::RAW_CONTACT); 87 std::vector<OHOS::DataShare::DataShareValuesBucket> values; 88 for (int i = 0; i < 10000; i++) { 89 OHOS::DataShare::DataShareValuesBucket rawContactValues; 90 std::string name("xiaoyan"); 91 name.append(std::to_string(i + 1)); 92 rawContactValues.Put("display_name", name); 93 rawContactValues.Put("company", "company"); 94 rawContactValues.Put("position", "position"); 95 values.push_back(rawContactValues); 96 } 97 HILOG_INFO("raw_contact_insert_performance_test_900 start! "); 98 int64_t startTime, endTime; 99 int elaps; 100 startTime = GetCurrentTime(); 101 int batchInsertCode = contactsDataAbility.BatchInsert(uriRawContact, values); 102 endTime = GetCurrentTime(); 103 elaps = CalcTime(startTime, endTime); 104 HILOG_INFO("raw_contact_insert_performance_test_900 : time is %{public}d", elaps); 105 ASSERT_LE(elaps, TIME_USEC_RAW_CONTACT_INSERT); 106 HILOG_INFO("raw_contact_insert_performance_test_900 finish! "); 107 HILOG_INFO("raw_contact_insert_performance_test_900 : batchInsertCode = %{public}d", batchInsertCode); 108 EXPECT_EQ(batchInsertCode, 0); 109} 110 111/* 112 * @tc.number raw_contact_update_performance_test_1000 113 * @tc.name raw_contact performance testing update 10000 114 * @tc.desc update 10000 115 * @tc.level Level1 116 * @tc.size MediumTest 117 * @tc.type Function 118 */ 119HWTEST_F(PerformanceTest, raw_contact_update_performance_test_1000, testing::ext::TestSize.Level1) 120{ 121 HILOG_INFO("--- raw_contact_update_performance_test_1000 is starting! ---"); 122 OHOS::Uri uriRawContact(ContactsUri::RAW_CONTACT); 123 OHOS::DataShare::DataShareValuesBucket updateValues; 124 updateValues.Put("favorite", 1); 125 OHOS::DataShare::DataSharePredicates predicates; 126 predicates.GreaterThan("id", "0"); 127 predicates.And(); 128 predicates.EqualTo("is_deleted", "0"); 129 HILOG_INFO("raw_contact_update_performance_test_1000 start! "); 130 int64_t startTime, endTime; 131 int elaps; 132 startTime = GetCurrentTime(); 133 int updateCode = contactsDataAbility.Update(uriRawContact, predicates, updateValues); 134 endTime = GetCurrentTime(); 135 elaps = CalcTime(startTime, endTime); 136 HILOG_INFO("raw_contact_update_performance_test_1000 : time is %{public}d", elaps); 137 ASSERT_LE(elaps, TIME_USEC_RAW_CONTACT_UPDATE); 138 EXPECT_EQ(updateCode, 0); 139} 140 141/* 142 * @tc.number raw_contact_query_performance_test_1100 143 * @tc.name raw_contact performance testing query 10000 144 * @tc.desc query 10000 145 * @tc.level Level1 146 * @tc.size MediumTest 147 * @tc.type Function 148 */ 149HWTEST_F(PerformanceTest, raw_contact_query_performance_test_1100, testing::ext::TestSize.Level1) 150{ 151 HILOG_INFO("--- raw_contact_query_performance_test_1100 is starting! ---"); 152 OHOS::Uri uriRawContact(ContactsUri::RAW_CONTACT); 153 std::vector<std::string> columns; 154 columns.push_back("id"); 155 columns.push_back("display_name"); 156 columns.push_back("company"); 157 columns.push_back("position"); 158 OHOS::DataShare::DataSharePredicates predicates; 159 predicates.GreaterThan("id", "0"); 160 predicates.And(); 161 predicates.EqualTo("is_deleted", "0"); 162 HILOG_INFO("raw_contact_query_performance_test_1100 start! "); 163 int64_t startTime, endTime; 164 int elaps; 165 startTime = GetCurrentTime(); 166 std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = 167 contactsDataAbility.Query(uriRawContact, predicates, columns); 168 int rowCount = 0; 169 resultSet->GetRowCount(rowCount); 170 EXPECT_GT(rowCount, 9999); 171 endTime = GetCurrentTime(); 172 elaps = CalcTime(startTime, endTime); 173 resultSet->Close(); 174 HILOG_INFO("raw_contact_query_performance_test_1100 : time is %{public}d", elaps); 175 ASSERT_LE(elaps, TIME_USEC_RAW_CONTACT_QUERY); 176} 177 178/* 179 * @tc.number raw_contact_delete_performance_test_1200 180 * @tc.name raw_contact performance testing delete 10000 181 * @tc.desc delete 10000 182 * @tc.level Level1 183 * @tc.size MediumTest 184 * @tc.type Function 185 */ 186HWTEST_F(PerformanceTest, raw_contact_delete_performance_test_1200, testing::ext::TestSize.Level1) 187{ 188 HILOG_INFO("--- raw_contact_delete_performance_test_1200 is starting! ---"); 189 OHOS::Uri uriRawContact(ContactsUri::RAW_CONTACT); 190 OHOS::DataShare::DataSharePredicates predicates; 191 predicates.GreaterThan("id", "0"); 192 predicates.And(); 193 predicates.EqualTo("is_deleted", "0"); 194 HILOG_INFO("raw_contact_delete_performance_test_1200 start! "); 195 int64_t startTime, endTime; 196 int elaps; 197 startTime = GetCurrentTime(); 198 int deleteCode = contactsDataAbility.Delete(uriRawContact, predicates); 199 endTime = GetCurrentTime(); 200 elaps = CalcTime(startTime, endTime); 201 HILOG_INFO("raw_contact_delete_performance_test_1200 : time is %{public}d", elaps); 202 ASSERT_LE(elaps, TIME_USEC_RAW_CONTACT_DELETED); 203 HILOG_INFO("raw_contact_delete_performance_test_1200 : deleteCode = %{public}d", deleteCode); 204 EXPECT_EQ(deleteCode, 0); 205} 206 207/* 208 * @tc.number contact_data_insert_performance_test_1300 209 * @tc.name contact_data performance testing add 10000 210 * @tc.desc add 10000 211 * @tc.level Level1 212 * @tc.size MediumTest 213 * @tc.type Function 214 */ 215HWTEST_F(PerformanceTest, contact_data_insert_performance_test_1300, testing::ext::TestSize.Level1) 216{ 217 OHOS::Uri uriRawContact(ContactsUri::RAW_CONTACT); 218 OHOS::DataShare::DataShareValuesBucket rawContactValues; 219 std::string rawName("xiaoyan"); 220 rawContactValues.Put("display_name", rawName); 221 rawContactValues.Put("company", "company"); 222 rawContactValues.Put("position", "position"); 223 int rawContactId = contactsDataAbility.Insert(uriRawContact, rawContactValues); 224 OHOS::DataShare::DataSharePredicates predicates; 225 predicates.NotEqualTo("id", "0"); 226 predicates.And(); 227 predicates.EqualTo("is_deleted", "0"); 228 contactsDataAbility.Delete(uriRawContact, predicates); 229 HILOG_INFO("--- contact_data_insert_performance_test_1300 is starting! ---"); 230 OHOS::Uri uriContactData(ContactsUri::CONTACT_DATA); 231 std::vector<OHOS::DataShare::DataShareValuesBucket> values; 232 for (int i = 0; i < 10000; i++) { 233 OHOS::DataShare::DataShareValuesBucket contactDataValues; 234 std::string name("xiaoyan"); 235 name.append(std::to_string(i + 1)); 236 contactDataValues.Put("raw_contact_id", rawContactId); 237 contactDataValues.Put("content_type", "name"); 238 contactDataValues.Put("detail_info", name); 239 values.push_back(contactDataValues); 240 } 241 HILOG_INFO("contact_data_insert_performance_test_1300 start! "); 242 int64_t startTime, endTime; 243 int elaps; 244 startTime = GetCurrentTime(); 245 int batchInsertCode = contactsDataAbility.BatchInsert(uriContactData, values); 246 endTime = GetCurrentTime(); 247 elaps = CalcTime(startTime, endTime); 248 HILOG_INFO("contact_data_insert_performance_test_1300 : time is %{public}d", elaps); 249 ASSERT_LE(elaps, TIME_USEC_CONTACT_DATA_INSERT); 250 EXPECT_EQ(batchInsertCode, 0); 251} 252 253/* 254 * @tc.number contact_data_update_performance_test_1400 255 * @tc.name contact_data performance testing update 10000 256 * @tc.desc update 10000 257 * @tc.level Level1 258 * @tc.size MediumTest 259 * @tc.type Function 260 */ 261HWTEST_F(PerformanceTest, contact_data_update_performance_test_1400, testing::ext::TestSize.Level1) 262{ 263 HILOG_INFO("--- contact_data_update_performance_test_1400 is starting! ---"); 264 OHOS::Uri uriContactData(ContactsUri::CONTACT_DATA); 265 OHOS::DataShare::DataShareValuesBucket updateValues; 266 updateValues.Put("syn_1", "test"); 267 OHOS::DataShare::DataSharePredicates predicates; 268 predicates.GreaterThan("id", "0"); 269 int64_t startTime, endTime; 270 int elaps; 271 startTime = GetCurrentTime(); 272 int updateCode = contactsDataAbility.Update(uriContactData, predicates, updateValues); 273 endTime = GetCurrentTime(); 274 elaps = CalcTime(startTime, endTime); 275 HILOG_INFO("contact_data_update_performance_test_1400 : time is %{public}d", elaps); 276 ASSERT_LE(elaps, TIME_USEC_CONTACT_DATA_UPDATE); 277 EXPECT_EQ(updateCode, 0); 278} 279 280/* 281 * @tc.number contact_data_query_performance_test_1500 282 * @tc.name contact_data performance testing query 10000 283 * @tc.desc query 10000 284 * @tc.level Level1 285 * @tc.size MediumTest 286 * @tc.type Function 287 */ 288HWTEST_F(PerformanceTest, contact_data_query_performance_test_1500, testing::ext::TestSize.Level1) 289{ 290 HILOG_INFO("--- contact_data_query_performance_test_1500 is starting! ---"); 291 OHOS::Uri uriContactData(ContactsUri::CONTACT_DATA); 292 std::vector<std::string> columns; 293 columns.push_back("raw_contact_id"); 294 columns.push_back("detail_info"); 295 OHOS::DataShare::DataSharePredicates predicates; 296 predicates.GreaterThan("id", "0"); 297 int64_t startTime, endTime; 298 int elaps; 299 startTime = GetCurrentTime(); 300 std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = 301 contactsDataAbility.Query(uriContactData, predicates, columns); 302 int rowCount = 0; 303 resultSet->GetRowCount(rowCount); 304 EXPECT_GT(rowCount, 9999); 305 endTime = GetCurrentTime(); 306 elaps = CalcTime(startTime, endTime); 307 resultSet->Close(); 308 HILOG_INFO("contact_data_query_performance_test_1500 : time is %{public}d", elaps); 309 ASSERT_LE(elaps, TIME_USEC_CONTACT_DATA_QUERY); 310} 311 312/* 313 * @tc.number contact_data_delete_performance_test_1600 314 * @tc.name contact_data performance testing delete 10000 315 * @tc.desc delete 10000 316 * @tc.level Level1 317 * @tc.size MediumTest 318 * @tc.type Function 319 */ 320HWTEST_F(PerformanceTest, contact_data_delete_performance_test_1600, testing::ext::TestSize.Level1) 321{ 322 HILOG_INFO("--- contact_data_delete_performance_test_1600 is starting! ---"); 323 OHOS::Uri uriContactData(ContactsUri::CONTACT_DATA); 324 OHOS::DataShare::DataSharePredicates predicates; 325 predicates.GreaterThan("id", "0"); 326 int64_t startTime, endTime; 327 int elaps; 328 startTime = GetCurrentTime(); 329 int deleteCode = contactsDataAbility.Delete(uriContactData, predicates); 330 endTime = GetCurrentTime(); 331 elaps = CalcTime(startTime, endTime); 332 HILOG_INFO("contact_data_delete_performance_test_1600 : time is %{public}d", elaps); 333 ASSERT_LE(elaps, TIME_USEC_CONTACT_DATA_DELETED); 334 EXPECT_EQ(deleteCode, 0); 335} 336 337/* 338 * @tc.number calllog_insert_performance_test_100 339 * @tc.name calllog calllog performance testing add 10000 340 * @tc.desc add 10000 341 * @tc.level Level1 342 * @tc.size MediumTest 343 * @tc.type Function 344 */ 345HWTEST_F(PerformanceTest, calllog_insert_performance_test_100, testing::ext::TestSize.Level1) 346{ 347 OHOS::Uri uriCalllog(CallLogUri::CALL_LOG); 348 OHOS::DataShare::DataSharePredicates predicatesOne; 349 predicatesOne.GreaterThan("id", "0"); 350 HILOG_INFO("calllog_insert_performance_test_100 deleted start! "); 351 calllogAbility.Delete(uriCalllog, predicatesOne); 352 HILOG_INFO("--- calllog_insert_performance_test_100 is starting! ---"); 353 std::vector<OHOS::DataShare::DataShareValuesBucket> values; 354 for (int i = 0; i < 10000; i++) { 355 OHOS::DataShare::DataShareValuesBucket calllogValues; 356 calllogValues.Put("phone_number", std::to_string(i + 1)); 357 values.push_back(calllogValues); 358 } 359 int64_t startTime, endTime; 360 int elaps; 361 startTime = GetCurrentTime(); 362 int batchInsertCode = calllogAbility.BatchInsert(uriCalllog, values); 363 endTime = GetCurrentTime(); 364 elaps = CalcTime(startTime, endTime); 365 HILOG_INFO("calllog_insert_performance_test_100 : time is %{public}d", elaps); 366 ASSERT_LE(elaps, TIME_USEC_CALL_LOG_INSERT); 367 EXPECT_EQ(batchInsertCode, 0); 368} 369 370/* 371 * @tc.number calllog_update_performance_test_200 372 * @tc.name calllog calllog performance testing update 10000 373 * @tc.desc update 10000 374 * @tc.level Level1 375 * @tc.size MediumTest 376 * @tc.type Function 377 */ 378HWTEST_F(PerformanceTest, calllog_update_performance_test_200, testing::ext::TestSize.Level1) 379{ 380 HILOG_INFO("--- calllog_update_performance_test_200 is starting! ---"); 381 OHOS::Uri uriCalllog(CallLogUri::CALL_LOG); 382 OHOS::DataShare::DataShareValuesBucket updateValues; 383 updateValues.Put("answer_state", 1); 384 OHOS::DataShare::DataSharePredicates predicates; 385 predicates.GreaterThan("id", "0"); 386 int64_t startTime, endTime; 387 int elaps; 388 startTime = GetCurrentTime(); 389 int updateCode = calllogAbility.Update(uriCalllog, predicates, updateValues); 390 endTime = GetCurrentTime(); 391 elaps = CalcTime(startTime, endTime); 392 ASSERT_LE(elaps, TIME_USEC_CALL_LOG_UPDATE); 393 HILOG_INFO("calllog_update_performance_test_200 : time is %{public}d", elaps); 394 EXPECT_EQ(updateCode, 0); 395} 396 397/* 398 * @tc.number calllog_query_performance_test_300 399 * @tc.name calllog calllog performance testing query 10000 400 * @tc.desc query 10000 401 * @tc.level Level1 402 * @tc.size MediumTest 403 * @tc.type Function 404 */ 405HWTEST_F(PerformanceTest, calllog_query_performance_test_300, testing::ext::TestSize.Level1) 406{ 407 HILOG_INFO("--- calllog_query_performance_test_300 is starting! ---"); 408 OHOS::Uri uriCalllog(CallLogUri::CALL_LOG); 409 std::vector<std::string> columns; 410 columns.push_back("id"); 411 columns.push_back("phone_number"); 412 OHOS::DataShare::DataSharePredicates predicates; 413 predicates.GreaterThan("id", "0"); 414 int64_t startTime, endTime; 415 int elaps; 416 startTime = GetCurrentTime(); 417 std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = 418 calllogAbility.Query(uriCalllog, predicates, columns); 419 int rowCount = 0; 420 resultSet->GetRowCount(rowCount); 421 EXPECT_GT(rowCount, 9999); 422 resultSet->Close(); 423 endTime = GetCurrentTime(); 424 elaps = CalcTime(startTime, endTime); 425 HILOG_INFO("calllog_query_performance_test_300 : time is %{public}d", elaps); 426 ASSERT_LE(elaps, TIME_USEC_CALL_LOG_QUERY); 427} 428 429/* 430 * @tc.number calllog_delete_performance_test_400 431 * @tc.name calllog calllog performance testing delete 10000 432 * @tc.desc delete 10000 433 * @tc.level Level1 434 * @tc.size MediumTest 435 * @tc.type Function 436 */ 437HWTEST_F(PerformanceTest, calllog_delete_performance_test_400, testing::ext::TestSize.Level1) 438{ 439 HILOG_INFO("--- calllog_delete_performance_test_400 is starting! ---"); 440 OHOS::Uri uriCalllog(CallLogUri::CALL_LOG); 441 OHOS::DataShare::DataSharePredicates predicates; 442 predicates.GreaterThan("id", "0"); 443 int64_t startTime, endTime; 444 int elaps; 445 startTime = GetCurrentTime(); 446 int deleteCode = calllogAbility.Delete(uriCalllog, predicates); 447 endTime = GetCurrentTime(); 448 elaps = CalcTime(startTime, endTime); 449 HILOG_INFO("calllog_delete_performance_test_400 : time is %{public}d", elaps); 450 ASSERT_LE(elaps, TIME_USEC_CALL_LOG_DELETED); 451 EXPECT_EQ(deleteCode, 0); 452} 453 454/* 455 * @tc.number voicemail_insert_performance_test_500 456 * @tc.name voicemail performance testing delete 10000 457 * @tc.desc delete 10000 458 * @tc.level Level1 459 * @tc.size MediumTest 460 * @tc.type Function 461 */ 462HWTEST_F(PerformanceTest, voicemail_insert_performance_test_500, testing::ext::TestSize.Level1) 463{ 464 OHOS::Uri uriVoiceMail(VoicemailUri::VOICEMAIL); 465 OHOS::DataShare::DataSharePredicates predicatesOne; 466 predicatesOne.GreaterThan("id", "0"); 467 HILOG_INFO("voicemail_insert_performance_test_500 deleted start! "); 468 voicemailAbility.Delete(uriVoiceMail, predicatesOne); 469 HILOG_INFO("--- voicemail_insert_performance_test_500 is starting! ---"); 470 std::vector<OHOS::DataShare::DataShareValuesBucket> values; 471 for (int i = 0; i < 10000; i++) { 472 OHOS::DataShare::DataShareValuesBucket voicemailValues; 473 voicemailValues.Put("phone_number", std::to_string(i + 1)); 474 values.push_back(voicemailValues); 475 } 476 HILOG_INFO("voicemail_insert_performance_test_500 start! "); 477 int64_t startTime, endTime; 478 int elaps; 479 startTime = GetCurrentTime(); 480 int batchInsertCode = voicemailAbility.BatchInsert(uriVoiceMail, values); 481 endTime = GetCurrentTime(); 482 elaps = CalcTime(startTime, endTime); 483 HILOG_INFO("voicemail_insert_performance_test_500 : time is %{public}d", elaps); 484 ASSERT_LE(elaps, TIME_USEC_VOICEMAIL_INSERT); 485 EXPECT_EQ(batchInsertCode, 0); 486} 487 488/* 489 * @tc.number voicemail_update_performance_test_600 490 * @tc.name voicemail performance testing update 10000 491 * @tc.desc update 10000 492 * @tc.level Level1 493 * @tc.size MediumTest 494 * @tc.type Function 495 */ 496HWTEST_F(PerformanceTest, voicemail_update_performance_test_600, testing::ext::TestSize.Level1) 497{ 498 HILOG_INFO("--- voicemail_update_performance_test_600 is starting! ---"); 499 OHOS::Uri uriVoiceMail(VoicemailUri::VOICEMAIL); 500 OHOS::DataShare::DataShareValuesBucket updateValues; 501 updateValues.Put("origin_type", "origin"); 502 OHOS::DataShare::DataSharePredicates predicates; 503 predicates.GreaterThan("id", "0"); 504 int64_t startTime, endTime; 505 int elaps; 506 startTime = GetCurrentTime(); 507 int updateCode = voicemailAbility.Update(uriVoiceMail, predicates, updateValues); 508 endTime = GetCurrentTime(); 509 elaps = CalcTime(startTime, endTime); 510 HILOG_INFO("voicemail_update_performance_test_600 : time is %{public}d", elaps); 511 ASSERT_LE(elaps, TIME_USEC_VOICEMAIL_UPDATE); 512 EXPECT_EQ(updateCode, 0); 513} 514 515/* 516 * @tc.number voicemail_query_performance_test_700 517 * @tc.name voicemail performance testing query 10000 518 * @tc.desc query 10000 519 * @tc.level Level1 520 * @tc.size MediumTest 521 * @tc.type Function 522 */ 523HWTEST_F(PerformanceTest, voicemail_query_performance_test_700, testing::ext::TestSize.Level1) 524{ 525 HILOG_INFO("--- voicemail_query_performance_test_700 is starting! ---"); 526 std::string tag("voicemail_query_performance_test_700"); 527 OHOS::Uri uriVoiceMail(VoicemailUri::VOICEMAIL); 528 std::vector<std::string> columns; 529 columns.push_back("id"); 530 columns.push_back("phone_number"); 531 OHOS::DataShare::DataSharePredicates predicates; 532 predicates.GreaterThan("id", "0"); 533 HILOG_INFO("voicemail_query_performance_test_700 start! "); 534 int64_t startTime, endTime; 535 int elaps; 536 startTime = GetCurrentTime(); 537 std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = 538 voicemailAbility.Query(uriVoiceMail, predicates, columns); 539 int rowCount = 0; 540 resultSet->GetRowCount(rowCount); 541 EXPECT_GT(rowCount, 9999); 542 endTime = GetCurrentTime(); 543 elaps = CalcTime(startTime, endTime); 544 resultSet->Close(); 545 HILOG_INFO("voicemail_query_performance_test_700 : time is %{public}d", elaps); 546 ASSERT_LE(elaps, TIME_USEC_VOICEMAIL_QUERY); 547} 548 549/* 550 * @tc.number voicemail_delete_performance_test_800 551 * @tc.name voicemail performance testing delete 10000 552 * @tc.desc delete 10000 553 * @tc.level Level1 554 * @tc.size MediumTest 555 * @tc.type Function 556 */ 557HWTEST_F(PerformanceTest, voicemail_delete_performance_test_800, testing::ext::TestSize.Level1) 558{ 559 HILOG_INFO("--- voicemail_delete_performance_test_800 is starting! ---"); 560 OHOS::Uri uriVoiceMail(VoicemailUri::VOICEMAIL); 561 OHOS::DataShare::DataSharePredicates predicates; 562 predicates.GreaterThan("id", "0"); 563 HILOG_INFO("voicemail_delete_performance_test_800 start! "); 564 int64_t startTime, endTime; 565 int elaps; 566 startTime = GetCurrentTime(); 567 int deleteCode = voicemailAbility.Delete(uriVoiceMail, predicates); 568 endTime = GetCurrentTime(); 569 elaps = CalcTime(startTime, endTime); 570 HILOG_INFO("voicemail_delete_performance_test_800 : time is %{public}d", elaps); 571 ASSERT_LE(elaps, TIME_USEC_VOICEMAIL_DELETED); 572 EXPECT_EQ(deleteCode, 0); 573} 574 575HWTEST_F(PerformanceTest, PerformanceTestDeleted, testing::ext::TestSize.Level1) 576{ 577 DeleteContact(); 578} 579} // namespace Test 580} // namespace Contacts