提交 0c433417 编写于 作者: 杜庆泉's avatar 杜庆泉

增加UTSJSONObject get 速度测试

上级 27c60e10
...@@ -22522,22 +22522,25 @@ export function testJSONLarge() : Result { ...@@ -22522,22 +22522,25 @@ export function testJSONLarge() : Result {
return describe("JSON_large", () => { return describe("JSON_large", () => {
test('parse', () => { test('parse', () => {
// #ifdef APP-ANDROID // #ifdef APP-ANDROID
let startTime = System.currentTimeMillis() UTSAndroid.getDispatcher("io").async(function(_){
let listdata = JSON.parseArray<PICKER_ITEM_INFO>(allStr) let startTime = System.currentTimeMillis()
let spendTime = System.currentTimeMillis() - startTime let listdata = JSON.parseArray<PICKER_ITEM_INFO>(allStr)
let spendTime = System.currentTimeMillis() - startTime
console.log('指定类型转换耗时',spendTime,listdata!.length)
expect(listdata.length).toEqual(33);
expect(spendTime < 500).toEqual(true);
startTime = System.currentTimeMillis()
let listdata2 = JSON.parse(allStr)
spendTime = System.currentTimeMillis() - startTime
expect(listdata2 instanceof Array).toEqual(true);
let parseArray = listdata2 as Array
expect(parseArray.length).toEqual(33);
expect(spendTime < 300).toEqual(true);
console.log('不指定类型转换耗时',spendTime,listdata2)
},null)
console.log('指定类型转换耗时',spendTime,listdata!.length)
expect(listdata.length).toEqual(33);
expect(spendTime < 500).toEqual(true);
startTime = System.currentTimeMillis()
let listdata2 = JSON.parse(allStr)
spendTime = System.currentTimeMillis() - startTime
expect(listdata2 instanceof Array).toEqual(true);
let parseArray = listdata2 as Array
expect(parseArray.length).toEqual(33);
expect(spendTime < 300).toEqual(true);
console.log('不指定类型转换耗时',spendTime,listdata2)
// #endif // #endif
......
...@@ -62,6 +62,24 @@ export function testUTSJSONObject() : Result { ...@@ -62,6 +62,24 @@ export function testUTSJSONObject() : Result {
// #endif // #endif
}) })
test('get-speed', () => {
// #ifdef APP-ANDROID
const utsObj: UTSJSONObject = {} as any as UTSJSONObject
for (let i = 0; i < 100; i++) {
utsObj.set('' + i, '' + i)
}
console.log('--start--')
let startTime = Date.now()
for (let i = 0; i < 10000; i++) {
utsObj.getString('0')
}
let spendTime = Date.now() - startTime
expect(spendTime < 300).toEqual(true);
// #endif
})
test('assign-withtype', () => { test('assign-withtype', () => {
// #ifdef APP-ANDROID // #ifdef APP-ANDROID
type User = { type User = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册