Skip to content
Closed
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
2 changes: 1 addition & 1 deletion apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"lucide-react": "^1.24.0",
"pdfjs-dist": "6.1.200",
"pdfjs-dist": "^6.2.108",
"react": "^19.2.4",
"react-dom": "^19.2.7",
"sonner": "^2.0.7",
Expand Down
34 changes: 34 additions & 0 deletions benchmark.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const BROWSER_PROGRESS_STEPS = [
{ progressLabel: "Decoding audio", progressStage: "decode", progressPercent: 20 },
{ progressLabel: "Separating stems... (45%)", progressStage: "separate", progressPercent: 45 },
{ progressLabel: "Building rehearsal cues", progressStage: "analyze", progressPercent: 70 },
{ progressLabel: "Saving reusable features", progressStage: "persist", progressPercent: 90 }
] as const;

function findNextStepFind(currentPercent: number) {
return BROWSER_PROGRESS_STEPS.find((step) => step.progressPercent > currentPercent);
}

function findNextStepForLoop(currentPercent: number) {
for (let i = 0; i < BROWSER_PROGRESS_STEPS.length; i++) {
const step = BROWSER_PROGRESS_STEPS[i];
if (step.progressPercent > currentPercent) {
return step;
}
}
return undefined;
}

const ITERATIONS = 10_000_000;

console.time("find");
for (let i = 0; i < ITERATIONS; i++) {
findNextStepFind(50);
}
console.timeEnd("find");

console.time("for");
for (let i = 0; i < ITERATIONS; i++) {
findNextStepForLoop(50);
}
console.timeEnd("for");
48 changes: 48 additions & 0 deletions benchmark2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const BROWSER_PROGRESS_STEPS = [
{ progressLabel: "Decoding audio", progressStage: "decode", progressPercent: 20 },
{ progressLabel: "Separating stems... (45%)", progressStage: "separate", progressPercent: 45 },
{ progressLabel: "Building rehearsal cues", progressStage: "analyze", progressPercent: 70 },
{ progressLabel: "Saving reusable features", progressStage: "persist", progressPercent: 90 }
] as const;

function findNextStepFind(currentPercent: number) {
return BROWSER_PROGRESS_STEPS.find((step) => step.progressPercent > currentPercent);
}

function findNextStepForLoop(currentPercent: number) {
for (let i = 0; i < BROWSER_PROGRESS_STEPS.length; i++) {
const step = BROWSER_PROGRESS_STEPS[i];
if (step.progressPercent > currentPercent) {
return step;
}
}
return undefined;
}

function hardcoded(currentPercent: number) {
if (currentPercent < 20) return BROWSER_PROGRESS_STEPS[0];
if (currentPercent < 45) return BROWSER_PROGRESS_STEPS[1];
if (currentPercent < 70) return BROWSER_PROGRESS_STEPS[2];
if (currentPercent < 90) return BROWSER_PROGRESS_STEPS[3];
return undefined;
}

const ITERATIONS = 10_000_000;

console.time("find");
for (let i = 0; i < ITERATIONS; i++) {
findNextStepFind(50);
}
console.timeEnd("find");

console.time("for");
for (let i = 0; i < ITERATIONS; i++) {
findNextStepForLoop(50);
}
console.timeEnd("for");

console.time("hardcoded");
for (let i = 0; i < ITERATIONS; i++) {
hardcoded(50);
}
console.timeEnd("hardcoded");
Comment on lines +30 to +48

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win

두 벤치마크의 측정 결과를 관찰 가능하고 대표적인 입력으로 수집하세요. 현재 호출 결과를 버리고 하나의 입력만 반복하므로 최적화 영향을 배제하지 못하고 모든 탐색 경로의 성능을 대표하지 못합니다.

  • benchmark2.ts#L30-L48: 세 구현의 반환값을 sink에 누적하고, 임계값 전후와 >= 90 입력을 워밍업 후 여러 라운드로 측정하세요.
  • benchmark.ts#L22-L34: 두 구현의 반환값을 같은 sink에 누적하고 동일한 입력 집합과 측정 라운드를 사용하세요.
📍 Affects 2 files
  • benchmark2.ts#L30-L48 (this comment)
  • benchmark.ts#L22-L34
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@benchmark2.ts` around lines 30 - 48, Update benchmark2.ts lines 30-48 and
benchmark.ts lines 22-34 so every implementation’s return value is accumulated
into a shared observable sink rather than discarded; warm up and measure
multiple rounds using the same representative input set covering values around
the threshold and inputs >=90, while preserving each benchmark’s existing
implementations.

Loading
Loading