Skip to content

Commit 50444c0

Browse files
authored
Scheduler: Stabilize performance test (#30319) (#30327)
Co-authored-by: Vladimir Bushmanov <[email protected]>
1 parent d35ee75 commit 50444c0

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
beforeAll, describe, expect, it,
2+
beforeAll, describe, expect, it, jest,
33
} from '@jest/globals';
44

55
import { globalCache } from './global_cache';
@@ -12,20 +12,18 @@ describe('timezone utils', () => {
1212
});
1313

1414
describe('calculateTimezoneByValue', () => {
15-
it('should work faster after first run', () => {
16-
let now = Date.now();
15+
it('should cache the results', () => {
1716
timeZoneList.value.forEach((timezone) => {
1817
timeZoneUtils.calculateTimezoneByValue(timezone);
1918
});
20-
const delta1 = Date.now() - now; // 41
21-
now = Date.now();
19+
20+
jest.spyOn(Intl, 'DateTimeFormat');
2221
timeZoneList.value.forEach((timezone) => {
2322
timeZoneUtils.calculateTimezoneByValue(timezone);
2423
});
25-
const delta2 = Date.now() - now; // 6
2624

2725
expect(globalCache.timezones.size).toBe(timeZoneList.value.length);
28-
expect(delta2).toBeLessThan(delta1 / 5);
26+
expect(Intl.DateTimeFormat).toHaveBeenCalledTimes(0);
2927
});
3028
});
3129
});

0 commit comments

Comments
 (0)