diff --git a/incremental/compat/src/arkts/observable.ts b/incremental/compat/src/arkts/observable.ts index 43ad4ae28ed6443ab01aa88a0f8b33bf0601bfca..1abea6ae320b614f987ea05360d10afd6889ba2f 100644 --- a/incremental/compat/src/arkts/observable.ts +++ b/incremental/compat/src/arkts/observable.ts @@ -181,7 +181,7 @@ export function observableProxyArray(...value: Value[]): Array { return observableProxy(Array.of(...value)) } -const PROXY_DISABLED = true // because of ArkTS Reflection performance +const PROXY_DISABLED = false // because of ArkTS Reflection performance /** @internal */ export function observableProxy(value: Value, parent?: ObservableHandler, observed?: boolean, strict: boolean = true): Value { diff --git a/incremental/demo-playground/src/main.ts b/incremental/demo-playground/src/main.ts index a4ff32a38b5a9b4dda49e577ff9f33c2661dd2ec..b5c185124d18af99553a0243352f14619010d483 100644 --- a/incremental/demo-playground/src/main.ts +++ b/incremental/demo-playground/src/main.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import { uint32 } from "@koalaui/common" +import { observableProxyArray, uint32 } from "@koalaui/common" import { CONTEXT_ROOT_SCOPE, IncrementalNode, NodeAttach, ReadonlyTreeNode, contextLocalValue, memoRoot, mutableState, updateStateManager, } from "@koalaui/runtime" @@ -72,4 +72,21 @@ state.value = 19 updateStateManager() // Compute the next frame. console.log(root.value.toHierarchy()) -console.log("-----END-----") \ No newline at end of file +console.log("-----END-----") + +function performance(count: number, proxy: boolean) { + const s = mutableState>( + proxy + ? observableProxyArray() + : new Array() + ) + const t1 = Date.now() + for (let i = 0; i < count; i++) { + s.value.push(count) + s.value.pop() + } + const t2 = Date.now() + console.log("count:", count, " proxy:", proxy, " time:", t2 - t1) +} +performance(1000000, false) +performance(1000, true)