Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions apps/mcp-server/src/tui/components/live.pure.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,28 +152,36 @@ describe('tui/components/live.pure', () => {
it('1분 동안 5회 호출 → "5.0/min"', () => {
const samples: ActivitySample[] = [
{ timestamp: 0, toolCalls: 0 },
{ timestamp: 60000, toolCalls: 5 },
{ timestamp: 60, toolCalls: 5 },
];
expect(computeThroughput(samples)).toBe('5.0/min');
});

it('30초 동안 3회 호출 → "6.0/min"', () => {
const samples: ActivitySample[] = [
{ timestamp: 0, toolCalls: 0 },
{ timestamp: 30000, toolCalls: 3 },
{ timestamp: 30, toolCalls: 3 },
];
expect(computeThroughput(samples)).toBe('6.0/min');
});

it('여러 샘플의 총합으로 계산', () => {
const samples: ActivitySample[] = [
{ timestamp: 0, toolCalls: 1 },
{ timestamp: 30000, toolCalls: 2 },
{ timestamp: 60000, toolCalls: 3 },
{ timestamp: 30, toolCalls: 2 },
{ timestamp: 60, toolCalls: 3 },
];
// 총 toolCalls = 1+2+3 = 6, 기간 = 60초 = 1분 → 6.0/min
expect(computeThroughput(samples)).toBe('6.0/min');
});

it('역순 타임스탬프 → "0.0/min" (가드)', () => {
const samples: ActivitySample[] = [
{ timestamp: 60, toolCalls: 2 },
{ timestamp: 0, toolCalls: 3 },
];
expect(computeThroughput(samples)).toBe('0.0/min');
});
});

describe('formatTimeWithSeconds', () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/mcp-server/src/tui/components/live.pure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function computeThroughput(samples: ActivitySample[]): string {
if (samples.length <= 1) return '0.0/min';
const first = samples[0];
const last = samples[samples.length - 1];
const durationMin = (last.timestamp - first.timestamp) / 60000;
const durationMin = (last.timestamp - first.timestamp) / 60;
if (durationMin <= 0) return '0.0/min';
const totalCalls = samples.reduce((sum, s) => sum + s.toolCalls, 0);
return `${(totalCalls / durationMin).toFixed(1)}/min`;
Expand Down
Loading