Skip to content

Commit

Permalink
test(queryClient): Adjust performance threshholds
Browse files Browse the repository at this point in the history
The pipeline was found to sometimes exceed the threshold of 500ms.
Since I expect the the required time to increase linearly, increase the row count by *1.5 and quadruple the time-threshhold.
  • Loading branch information
Sebastian Kranz committed Feb 19, 2024
1 parent 5ab1d25 commit 9db4d89
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions packages/query-core/src/tests/queryClient.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,14 +357,14 @@ describe('queryClient', () => {
)
})

test('should set 10k data in less than 500ms', () => {
test('should set 15k data in less than 2000ms', () => {
const key = queryKey()
const start = performance.now()
for (let i = 0; i < 10000; i++) {
for (let i = 0; i < 15000; i++) {
queryClient.setQueryData([key, i], i)
}
const end = performance.now()
expect(end - start).toBeLessThan(500)
expect(end - start).toBeLessThan(2000)
})
})

Expand Down Expand Up @@ -430,36 +430,36 @@ describe('queryClient', () => {
expect(queryClient.getQueryData([key])).toBeUndefined()
})

test('should get 10k queries in less than 500ms', () => {
test('should get 15k queries in less than 2000ms', () => {
const key = queryKey()
for (let i = 0; i < 10000; i++) {
for (let i = 0; i < 15000; i++) {
queryClient.setQueryData([key, i], i)
}

const start = performance.now()
for (let i = 0; i < 10000; i++) {
for (let i = 0; i < 15000; i++) {
queryClient.getQueryData([key, i])
}
const end = performance.now()

expect(end - start).toBeLessThan(500)
expect(end - start).toBeLessThan(2000)
})
})

describe('getQueryState', () => {
test('should get 10k queries in less than 500ms', () => {
test('should get 15k queries in less than 2000ms', () => {
const key = queryKey()
for (let i = 0; i < 10000; i++) {
for (let i = 0; i < 15000; i++) {
queryClient.setQueryData([key, i], i)
}

const start = performance.now()
for (let i = 0; i < 10000; i++) {
for (let i = 0; i < 15000; i++) {
queryClient.getQueryState([key, i])
}
const end = performance.now()

expect(end - start).toBeLessThan(500)
expect(end - start).toBeLessThan(2000)
})
})

Expand Down

0 comments on commit 9db4d89

Please sign in to comment.