代码拉取完成,页面将自动刷新
同步操作将从 OpenHarmony Development Docs/Starts 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*
* Copyright (C) 2023 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import dataRdb from '@ohos.data.relationalStore';
import featureAbility from '@ohos.ability.featureAbility';
const TAG = "[RDB_JSKITS _TEST]"
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY AUTOINCREMENT, "
+ "name TEXT, age INTEGER, salary REAL, blobType BLOB)";
const STORE_CONFIG = {
name: "RelationalStoreInsertPromise.db",
securityLevel: dataRdb.SecurityLevel.S1
}
var rdbStore = undefined;
const BASE_COUNT = 2000 // 循环次数: 测试普通接口性能
export default function RelationalStoreInsertPromise() {
describe('RelationalStoreInsertPromise', function () {
beforeAll(async function () {
console.info(TAG + 'beforeAll')
rdbStore = await dataRdb.getRdbStore(globalThis.context, STORE_CONFIG);
})
beforeEach(async function () {
console.info(TAG + 'beforeEach')
await rdbStore.executeSql(CREATE_TABLE_TEST, null);
})
afterEach(async function () {
console.info(TAG + 'afterEach')
await rdbStore.executeSql("delete from test");
})
afterAll(async function () {
console.info(TAG + 'afterAll')
rdbStore = null
await dataRdb.deleteRdbStore(globalThis.context, STORE_CONFIG.name);
})
console.log(TAG + "*************Unit Test Begin*************");
it('SUB_DDM_PERF_RelationalStor_insert_Promise_001', 0, async function (done) {
let averageTime = 0;
var uBlob = new Uint8Array([1, 2, 3])
var insertValueBucket = {
"name": "zhangsan",
"age": 18,
"salary": 100.5,
"blobType": uBlob,
}
let startTime = new Date().getTime() //结束时间
InsertPromiseTest(0)
function InsertPromiseTest(index) {
let promise = rdbStore.insert("test", insertValueBucket)
promise.then(data => {
if (index < BASE_COUNT) {
InsertPromiseTest(index + 1)
} else {
let endTime = new Date().getTime() //结束时间
averageTime = ((endTime - startTime) * 1000) / BASE_COUNT
console.info(TAG + "SUB_DDM_PERF_RelationalStor_insert_Promise_001 averageTime: " + averageTime + " us")
done();
expect(true).assertTrue();
}
});
}
})
})
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。