加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
errorcode 2.89 KB
一键复制 编辑 原始数据 按行查看 历史
mangtsang 提交于 2023-07-24 11:39 . update errorcode.
/*
* 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();
}
});
}
})
})
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化