perf: batch signals

This commit is contained in:
kunish 2023-09-17 03:15:14 +08:00
parent e04ec712ea
commit 0015468077
No known key found for this signature in database
GPG Key ID: 647A12B4F782C430

View File

@ -7,6 +7,7 @@ import { SolidApexCharts } from 'solid-apexcharts'
import { import {
JSX, JSX,
ParentComponent, ParentComponent,
batch,
children, children,
createEffect, createEffect,
createMemo, createMemo,
@ -36,8 +37,10 @@ export default () => {
// TODO: needs a better way // TODO: needs a better way
makeTimer( makeTimer(
() => { () => {
setTraffics((traffics) => traffics.slice(-CHART_MAX_XAXIS)) batch(() => {
setMemories((memo) => memo.slice(-CHART_MAX_XAXIS)) setTraffics((traffics) => traffics.slice(-CHART_MAX_XAXIS))
setMemories((memo) => memo.slice(-CHART_MAX_XAXIS))
})
}, },
// we shrink the chart data array size down every 10 minutes to prevent memory leaks // we shrink the chart data array size down every 10 minutes to prevent memory leaks
10 * 60 * 1000, 10 * 60 * 1000,