mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-13 23:51:16 -07:00
fix(core): fix startup stats to use int values for timestamps and durations (#22201)
Co-authored-by: Yuna Seol <yunaseol@google.com>
This commit is contained in:
@@ -388,5 +388,32 @@ describe('StartupProfiler', () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('should log startup stats timestamps as rounded integers', () => {
|
||||
const handle = profiler.start('test_phase');
|
||||
handle?.end();
|
||||
|
||||
profiler.flush(mockConfig);
|
||||
|
||||
const statsEvent = logStartupStats.mock.calls[0][1];
|
||||
const phase = statsEvent.phases[0];
|
||||
|
||||
// Verify they are integers
|
||||
expect(Number.isInteger(phase.start_time_usec)).toBe(true);
|
||||
expect(Number.isInteger(phase.end_time_usec)).toBe(true);
|
||||
});
|
||||
|
||||
it('should log startup stats duration as rounded integers', () => {
|
||||
const handle = profiler.start('test_phase');
|
||||
handle?.end();
|
||||
|
||||
profiler.flush(mockConfig);
|
||||
|
||||
const statsEvent = logStartupStats.mock.calls[0][1];
|
||||
const phase = statsEvent.phases[0];
|
||||
|
||||
// Verify they are integers
|
||||
expect(Number.isInteger(phase.duration_ms)).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -207,13 +207,16 @@ export class StartupProfiler {
|
||||
if (measure && phase.cpuUsage) {
|
||||
startupPhases.push({
|
||||
name: phase.name,
|
||||
duration_ms: measure.duration,
|
||||
duration_ms: Math.round(measure.duration),
|
||||
cpu_usage_user_usec: phase.cpuUsage.user,
|
||||
cpu_usage_system_usec: phase.cpuUsage.system,
|
||||
start_time_usec: (performance.timeOrigin + measure.startTime) * 1000,
|
||||
end_time_usec:
|
||||
start_time_usec: Math.round(
|
||||
(performance.timeOrigin + measure.startTime) * 1000,
|
||||
),
|
||||
end_time_usec: Math.round(
|
||||
(performance.timeOrigin + measure.startTime + measure.duration) *
|
||||
1000,
|
||||
1000,
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user