diff --git a/tests/proxyMap.test.tsx b/tests/proxyMap.test.tsx index 842d3568..530a6988 100644 --- a/tests/proxyMap.test.tsx +++ b/tests/proxyMap.test.tsx @@ -307,6 +307,35 @@ describe('delete', () => { }) }) +describe('performance', () => { + it('should not be slow as linear growth', () => { + const state = proxyMap() + + let operation100Time: number + { + const start = performance.now() + for (let i = 0; i < 100; i++) { + state.set(i, i) + } + const end = performance.now() + operation100Time = end - start + } + + let operation1000Time: number + { + const start = performance.now() + for (let i = 0; i < 1000; i++) { + state.set(i, i) + } + const end = performance.now() + operation1000Time = end - start + } + + const ratio = operation1000Time / operation100Time + expect(ratio).toBeLessThan(10) + }) +}) + describe('proxyMap internal', () => { it('should be sealed', () => { expect(Object.isSealed(proxySet())).toBe(true) diff --git a/tests/proxySet.test.tsx b/tests/proxySet.test.tsx index 74d1db39..c22382de 100644 --- a/tests/proxySet.test.tsx +++ b/tests/proxySet.test.tsx @@ -323,6 +323,35 @@ describe('delete', () => { }) }) +describe('performance', () => { + it('should not be slow as linear growth', () => { + const state = proxySet() + + let operation100Time: number + { + const start = performance.now() + for (let i = 0; i < 100; i++) { + state.add(i) + } + const end = performance.now() + operation100Time = end - start + } + + let operation1000Time: number + { + const start = performance.now() + for (let i = 0; i < 1000; i++) { + state.add(i) + } + const end = performance.now() + operation1000Time = end - start + } + + const ratio = operation1000Time / operation100Time + expect(ratio).toBeLessThan(10) + }) +}) + describe('proxySet internal', () => { it('should be sealed', () => { expect(Object.isSealed(proxySet())).toBe(true)