From 923b79f0455007456ed79b7e06476568c36a8578 Mon Sep 17 00:00:00 2001 From: duqingquan Date: Wed, 4 Sep 2024 10:51:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=8B=E5=8A=A8=E5=A2=9E=E5=8A=A0=20UTSJSONO?= =?UTF-8?q?bject=20getSpeed=E6=B5=8B=E8=AF=95=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uts-tests/utssdk/UTSJSONObject.uts | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/uni_modules/uts-tests/utssdk/UTSJSONObject.uts b/uni_modules/uts-tests/utssdk/UTSJSONObject.uts index f5fa83d..da74536 100644 --- a/uni_modules/uts-tests/utssdk/UTSJSONObject.uts +++ b/uni_modules/uts-tests/utssdk/UTSJSONObject.uts @@ -1,7 +1,5 @@ import { describe, test, expect, expectNumber, Result } from './tests.uts' - - export function testUTSJSONObject() : Result { return describe("utsjsonobject", () => { test('keys', () => { @@ -12,6 +10,7 @@ export function testUTSJSONObject() : Result { expect(UTSJSONObject.keys(obj).length).toEqual(2); console.log(UTSJSONObject.keys(obj)) }) + test('toJSONObject', () => { // #ifdef APP-ANDROID let result = {} @@ -36,8 +35,7 @@ export function testUTSJSONObject() : Result { // #endif }) - - + test('assign-notype', () => { // #ifdef APP-ANDROID const target = { a: 1, b: 2 }; @@ -87,6 +85,24 @@ export function testUTSJSONObject() : Result { // #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', () => { // #ifdef APP-ANDROID type User = { @@ -102,4 +118,4 @@ export function testUTSJSONObject() : Result { // #endif }) }) -} \ No newline at end of file +} -- GitLab