提交 9fc4f2a8 编写于 作者: Z zhaoruiyuan

feat: add performance test

Signed-off-by: Nzhaoruiyuan <zhaoruiyuan2@huawei.com>
上级 93d6843a
...@@ -16,3 +16,4 @@ require('./battery_unit.test.js') ...@@ -16,3 +16,4 @@ require('./battery_unit.test.js')
require('./battery_common_event.test.js') require('./battery_common_event.test.js')
require('./power_manager_running_lock.test.js') require('./power_manager_running_lock.test.js')
require('./system_battery.test.js') require('./system_battery.test.js')
require('./batterymanager_performance.test.js')
\ No newline at end of file
+137/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
......
/*
* Copyright (C) 2022 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 batteryInfo from '@ohos.batteryInfo';
import {describe, it, expect} from 'deccjsunit/index';
describe('appInfoTest', function () {
console.log("*************Edited Battery Performance Test Begin*************");
const MAXNUM = 1000;
const MS_TO_US = 1000;
const LIMIT_TIME = 1000;
const HEALTH_LIMIT_TIME = 350;
/**
* @tc.number BatteryPerformance_001
* @tc.name battery_temperature_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_001', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.batteryTemperature;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BATTERY_Performance_001: Promise: batteryInfo.batteryTemperature Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
* @tc.number BatteryPerformance_002
* @tc.name battery_chargingstatus_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_002', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.chargingStatus;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BATTERY_Performance_002: Promise: batteryInfo.chargingStatus Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
* @tc.number BatteryPerformance_003
* @tc.name battery_healthstatus_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_003', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.healthStatus;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_003: Promise: batteryInfo.healthStatus Average Time : ${waitTime}`);
avgTime < HEALTH_LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
* @tc.number BatteryPerformance_004
* @tc.name battery_pluggedtype_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_004', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.pluggedType;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_004: Promise: batteryInfo.pluggedType Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
* @tc.number BatteryPerformance_005
* @tc.name battery_technology_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_005', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.technology;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_005: Promise: batteryInfo.technology Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
* @tc.number BatteryPerformance_006
* @tc.name battery_capacity_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_006', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.batterySOC;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_006: Promise: batteryInfo.batterySOC Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
* @tc.number BatteryPerformance_007
* @tc.name battery_voltage_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_007', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.voltage;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_007: Promise: batteryInfo.voltage Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
*@tc.number BatteryPerformance_008
* @tc.name is_battery_present_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_008', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.isBatteryPresent;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_008: Promise: batteryInfo.isBatteryPresent Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
*@tc.number BatteryPerformance_009
* @tc.name battery_capacity_level_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_009', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.batteryCapacityLevel;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_009: Promise: batteryInfo.batteryCapacityLevel Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
*@tc.number BatteryPerformance_010
* @tc.name estimated_remaining_chargeTime_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_010', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.estimatedRemainingChargeTime;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_010: Promise: batteryInfo.estimatedRemainingChargeTime
Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
*@tc.number BatteryPerformance_011
* @tc.name total_energy_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_011', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.totalEnergy;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_011: Promise: batteryInfo.totalEnergy Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
*@tc.number BatteryPerformance_012
* @tc.name now_current_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_012', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.nowCurrent;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_012: Promise: batteryInfo.nowCurrent Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
/**
*@tc.number BatteryPerformance_013
* @tc.name remaining_energy_test
* @tc.desc Battery acquisition kit
*/
it('BatteryPerformance_013', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
batteryInfo.remainingEnergy;
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`BatteryPerformance_013: Promise: batteryInfo.remainingEnergy Average Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
})
...@@ -14,3 +14,4 @@ ...@@ -14,3 +14,4 @@
*/ */
require('./power_manager_running_lock.test.js') require('./power_manager_running_lock.test.js')
require('./power_manager_power.test.js') require('./power_manager_power.test.js')
require('./power_performance_test.js')
/*
* Copyright (C) 2022 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 runningLock from '@ohos.runningLock';
import power from '@ohos.power';
import brightness from '@ohos.brightness';
import {describe, it, expect} from 'deccjsunit/index';
describe('appInfoTest', function () {
console.log("*************Power Performance Test Begin*************");
const MAXNUM = 1000;
const MIDNUM =100;
const MS_TO_US = 1000;
const LIMIT_TIME = 1500;
const LIMIT_TIME_LONG = 4000;
/**
* @tc.number PowerPerformance_001
* @tc.name createRunningLock_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_001', 0, async function (done) {
let startTime = new Date().getTime();
for (let i = 0; i < MIDNUM; i++) {
await runningLock.createRunningLock("test", runningLock.RunningLockType.BACKGROUND)
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MIDNUM * MS_TO_US; //us
console.info(`POWER_Performance_001: Promise: runningLock.createRunningLock Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME_LONG ? expect(true).assertTrue() : expect(false).assertTrue();
done();
})
/**
* @tc.number PowerPerformance_002
* @tc.name isUsed_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_002', 0, async function (done) {
let avgTime = 0;
runningLock.createRunningLock("test", runningLock.RunningLockType.BACKGROUND, (error, runningLock) => {
if (typeof error === "undefined") {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
runningLock.isUsed();
}
let waitTime = new Date().getTime() - startTime;
avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`PowerPerformance_002: Promise: runningLock.isUsed Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
done();
} else {
console.log('PowerPerformance_002: ' + error);
console.info('PowerPerformance_002: isUsed is ' + runningLock);
done();
}
})
})
/**
* @tc.number PowerPerformance_003
* @tc.name lock_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_003', 0, async function (done) {
let avgTime = 0;
runningLock.createRunningLock("test", runningLock.RunningLockType.BACKGROUND, (error, runningLock) => {
if (typeof error === "undefined") {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
runningLock.lock(500);
}
let waitTime = new Date().getTime() - startTime;
avgTime = avgTime + waitTime; //us
console.info(`PowerPerformance_003: Promise: runningLock.lock Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
runningLock.unlock();
done();
} else {
console.log('PowerPerformance_003: ' + error);
console.info('PowerPerformance_003: lock is ' + runningLock);
done();
}
})
})
/**
* @tc.number PowerPerformance_004
* @tc.name unlock_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_004', 0, async function (done) {
let avgTime = 0;
runningLock.createRunningLock("test", runningLock.RunningLockType.BACKGROUND, (error, runningLock) => {
if (typeof error === "undefined") {
runningLock.lock(500);
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
runningLock.unlock();
}
let waitTime = new Date().getTime() - startTime;
avgTime = avgTime + waitTime; //us
console.info(`PowerPerformance_004: Promise: runningLock.unlock Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
done();
} else {
console.log('PowerPerformance_004: ' + error);
console.info('PowerPerformance_004: lock is ' + runningLock);
done();
}
})
})
/**
* @tc.number PowerPerformance_005
* @tc.name isProximitySupported_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_005', 0, async function (done) {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
await runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL)
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`PowerPerformance_005: Promise: await runningLock.isRunningLockTypeSupported Wait Time :
${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
done();
})
/**
* @tc.number PowerPerformance_006
* @tc.name isScreenOn_test
* @tc.desc AsyncCallback<boolean> judge whether the screen is lit and return to true
*/
it('PowerPerformance_006', 0, async function (done) {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
await power.isScreenOn()
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`PowerPerformance_006: Promise: await power.isScreenOn Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
done();
})
/**
* @tc.number PowerPerformance_007
* @tc.name setValue_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_007', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
brightness.setValue(100);
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`PowerPerformance_007: Promise: brightness.setValue Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
})
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
*/ */
require('./WorkScheduler.test.js') require('./WorkScheduler.test.js')
require('./WorkSchedulerJs.performance.js')
......
/*
* Copyright (C) 2022 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 workscheduler from '@ohos.workScheduler'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe("WorkSchedulerJsTest", function () {
console.log("**********WorkScheduler Performance Test Begin**********")
performanceStartWork()
performanceStopWork()
performanceGetWorkStatusCallback()
performanceGetWorkStatusPromise()
performanceObtainAllWorksCallback()
performanceObtainAllWorksPromise()
performanceIsLastWorkTimeOutCallback()
performanceIsLastWorkTimeOutPromise()
performanceStopAndClearWorks()
console.log("**********WorkScheduler Performance Test End**********")
})
function performanceStartWork() {
it('WorkSchedulerPerformance_001', 0, async function(done) {
let totalTime = 0
let workInfo = {
workId: 201,
batteryStatus: workscheduler.BatteryStatus.BATTERY_STATUS_LOW,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
let startTime = new Date().getTime()
workscheduler.startWork(workInfo)
totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_001: startWork WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
}
function performanceStopWork() {
it('WorkSchedulerPerformance_002', 0, async function(done) {
let totalTime = 0
let workingInfo = {
workId: 202,
batteryStatus: workscheduler.BatteryStatus.BATTERY_STATUS_LOW,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workingInfo)
let workInfo = {
workId: 202,
batteryStatus: workscheduler.BatteryStatus.BATTERY_STATUS_LOW,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
let startTime = new Date().getTime()
workscheduler.stopWork(workInfo, false)
totalTime= new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_002: stopWork WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
}
function performanceGetWorkStatusCallback() {
it('WorkSchedulerPerformance_003', 0, async function(done) {
let workInfo = {
workId: 203,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
await workscheduler.getWorkStatus(203, (err, res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_003: getWorkStatus callback WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
})
}
function performanceGetWorkStatusPromise() {
it('WorkSchedulerPerformance_004', 0, async function(done) {
let workInfo = {
workId: 204,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
startTime = new Date().getTime()
await workscheduler.getWorkStatus(204)
.then((res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_004: getWorkStatus promise WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
.catch((err) => {
done()
})
})
}
function performanceObtainAllWorksCallback() {
it('WorkSchedulerPerformance_005', 0, async function(done) {
let workInfo = {
workId: 205,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
await workscheduler.obtainAllWorks((err, res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_005: obtainAllWorks callback WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
})
}
function performanceObtainAllWorksPromise() {
it('WorkSchedulerPerformance_006', 0, async function(done) {
let workInfo = {
workId: 206,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
await workscheduler.obtainAllWorks()
.then((res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_006: obtainAllWorks promise WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
.catch((err) => {
done()
})
})
}
function performanceIsLastWorkTimeOutCallback() {
it('WorkSchedulerPerformance_007', 0, async function(done) {
let workInfo = {
workId: 207,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
await workscheduler.isLastWorkTimeOut(207, (err, res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_007: isLastWorkTimeOut callback WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
})
}
function performanceIsLastWorkTimeOutPromise() {
it('WorkSchedulerPerformance_008', 0, async function(done) {
let workInfo = {
workId: 208,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
await workscheduler.isLastWorkTimeOut(208)
.then((res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_008: isLastWorkTimeOut promise WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
.catch((err) => {
done()
})
})
}
function performanceStopAndClearWorks() {
it('WorkSchedulerPerformance_009', 0, function() {
let workInfo = {
workId: 209,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
workscheduler.stopAndClearWorks()
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_009: stopAndClearWorks WaitTime: ' + totalTime + 'ms')
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册