Skip to content

Commit c5cf946

Browse files
committed
test(performance): test failed
1 parent 7fce04a commit c5cf946

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

packages/core/__tests__/performance.test.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,20 @@ describe('performance Optimization', () => {
155155
configureStyleProcessing({ enablePerformanceMonitoring: true })
156156
})
157157

158-
it('should track style calculations', () => {
158+
it('should track style calculations', async () => {
159159
const endTimer = performanceMonitor.startStyleCalculation()
160160

161161
// 模拟一些计算时间
162-
setTimeout(() => {
163-
endTimer()
162+
await new Promise(resolve =>
163+
setTimeout(() => {
164+
endTimer()
165+
resolve(true)
166+
}, 10),
167+
)
164168

165-
const metrics = performanceMonitor.getMetrics()
166-
expect(metrics.totalStyleCalculations).toBe(1)
167-
expect(metrics.averageCalculationTime).toBeGreaterThan(0)
168-
}, 10)
169+
const metrics = performanceMonitor.getMetrics()
170+
expect(metrics.totalStyleCalculations).toBe(1)
171+
expect(metrics.averageCalculationTime).toBeGreaterThan(0)
169172
})
170173

171174
it('should track cache hits and misses', () => {

packages/core/src/utils/performanceMonitor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class PerformanceMonitor {
8484
* 记录计算时间
8585
*/
8686
private recordCalculationTime(duration: number): void {
87+
console.log('duration', duration)
8788
this.metrics.totalStyleCalculations++
8889
this.calculationTimes.push(duration)
8990

0 commit comments

Comments
 (0)