Experiment DC56F1A: Reduce duration
Base 2799b7e Metric ID bbf2b1a
rad-experiment show dc56f1a4e4c826eb2af69b84e16d692073b17927
by vagrant · Apr 1 08:45 2026
Sum identity F(n+1)-1 eliminates summation loop
Delta-0.00%
Metricduration (ms)
Criterialower_is_better
LOC+6 -4
-010203040base123456789101112131415EXPERIMENTS
Kept Discarded Running best
Measurements
MetricBaselineCandidateDelta
duration (ms)How long the code takes to run. Less is better.0.000 ms (n=5)0.000 ms (n=5)-0.00%
p95 (ms)Measures p95 in ms. Less is better.0.000 ms0.000 ms-0.00%
ops_per_sec (ops/sec)Operations completed per second. More is better.1848429.880 ops/sec2178647.010 ops/sec+17.86%
Diff
~ src/index.ts
@@ -1,19 +1,21 @@
1 /** 2 * Compute the sum of the first `n` Fibonacci numbers. 3 * 4+ * Uses the identity: sum(F(0)..F(n-1)) = F(n+1) - 1 5 * For n = 30, the expected result is 1,346,268. 6 */ 7 export function sumFibonacci(n: number): number { 7- let sum = 0; 8+ if (n <= 0) return 0; 9+ 10+ // Compute F(n+1) iteratively 11 let a = 0; 12 let b = 1; 10- 13 for (let i = 0; i < n; i++) { 12- sum += a; 14 const next = a + b; 15 a = b; 16 b = next; 17 } 18 18- return sum; 19+ // sum(F(0)..F(n-1)) = F(n+1) - 1 20+ return b - 1; 21 }
Environment
Base commit2799b7e0c777f66c27231ebf9c73b1684f2ebe0c
Candidate commit7a7243a14b945e6fe6a8a232c1643baf681fe21d
Buildtrue
Teststrue
Metric IDbbf2b1a
Archaarch64
OSUbuntu 24.04
CPU
Agentclaude-code / claude-opus-4-6
Filessrc/index.ts