进一步优化

This commit is contained in:
CN-JS-HuiBai
2026-04-07 00:29:46 +08:00
parent 09887b52d0
commit f169dd4267
2 changed files with 14 additions and 18 deletions

View File

@@ -64,8 +64,8 @@ class AreaChart {
// Smoothly transition max value context too
this.prevMaxVal = this.currentMaxVal || 0;
// Downsample if data is too dense (target ~1500 points for performance)
const MAX_POINTS = 1500;
// Downsample if data is too dense (target ~500 points for GPU performance)
const MAX_POINTS = 500;
if (data.timestamps.length > MAX_POINTS) {
const skip = Math.ceil(data.timestamps.length / MAX_POINTS);
const downsampled = { timestamps: [], rx: [], tx: [] };
@@ -112,7 +112,7 @@ class AreaChart {
animate() {
if (this.animFrame) cancelAnimationFrame(this.animFrame);
const start = performance.now();
const duration = 800;
const duration = 400; // Shorter animation = less GPU time
const step = (now) => {
const elapsed = now - start;
@@ -277,7 +277,7 @@ class AreaChart {
drawArea(ctx, values, prevValues, getX, getY, chartH, p, fillColorTop, fillColorBottom, strokeColor, len) {
if (!values || values.length === 0) return;
const useSimple = len > 250;
const useSimple = len > 80;
const getPVal = (i) => (prevValues && i < prevValues.length) ? prevValues[i] : 0;
// Fill
@@ -407,7 +407,7 @@ class MetricChart {
animate() {
if (this.animFrame) cancelAnimationFrame(this.animFrame);
const start = performance.now();
const duration = 500;
const duration = 300; // Snappier and lighter on GPU
const step = (now) => {
const elapsed = now - start;
this.animProgress = Math.min(elapsed / duration, 1);
@@ -560,7 +560,7 @@ class MetricChart {
});
} else {
const useSimple = len > 250;
const useSimple = len > 100;
const prevVals = this.prevData ? this.prevData.values : null;
const getPVal = (i) => (prevVals && i < prevVals.length) ? prevVals[i] : 0;