{
  "auditMetadata": {
    "timestamp": "2026-10-11T07:05:00.000Z",
    "baselineCommit": "700fad8e7d4ee7111ebfe5be0cbf6dc4b5f9393a",
    "baselineBranch": "main",
    "candidateCommit": "8d36da4cfb06e8b4e76865fc21e4aeb657738f61",
    "candidateBranch": "perf/improve-time-complexity",
    "environment": {
      "node": "v22.14.0",
      "platform": "win32",
      "arch": "x64",
      "cpus": 12,
      "totalMemoryMb": 16384
    },
    "verdict": "APPROVED_AFTER_SPECIFIC_FIXES"
  },
  "syntheticBenchmarks": {
    "workloadDescription": "3,000 multi-source sports matches fixture with teams, aliases, categories",
    "trials": 5,
    "results": [
      {
        "id": "B1",
        "name": "Catalog Sorting (Schwartzian Transform)",
        "baselineComplexity": "O(N log N · K_regex)",
        "candidateComplexity": "O(N · K + N log N)",
        "trialDurationsMs": {
          "baseline": [690.45, 682.11, 715.30, 688.94, 695.12],
          "candidate": [75.21, 74.88, 76.50, 75.10, 74.32]
        },
        "medianBaselineMs": 690.45,
        "medianCandidateMs": 75.10,
        "speedup": "9.2x",
        "improvementPct": "89.1%",
        "correctness": "PASS (strict sort parity verified)"
      },
      {
        "id": "B2",
        "name": "Match Lookup Resolution (O(1) Map Index)",
        "baselineComplexity": "O(N) 4-tier linear scans",
        "candidateComplexity": "O(1) Hash Map index",
        "trialDurationsMs": {
          "baseline": [2798.12, 2814.50, 2750.30, 2971.32, 2840.10],
          "candidate": [152.40, 148.90, 160.20, 136.09, 150.15]
        },
        "medianBaselineMs": 2814.50,
        "medianCandidateMs": 150.15,
        "speedup": "18.7x",
        "improvementPct": "94.7%",
        "correctness": "PASS (100% match resolution parity)"
      },
      {
        "id": "B3",
        "name": "Database Read Memory Churn (Read-Only Reference)",
        "baselineComplexity": "O(N) Deep Clone (JSON.parse(JSON.stringify))",
        "candidateComplexity": "O(1) Direct Reference getMatchesReadOnly()",
        "trialDurationsMs": {
          "baseline": [228.40, 159.30, 195.40, 210.15, 185.70],
          "candidate": [0.17, 0.20, 0.16, 0.18, 0.15]
        },
        "medianBaselineMs": 195.40,
        "medianCandidateMs": 0.17,
        "speedup": "1149.4x",
        "improvementPct": "99.9%",
        "correctness": "PASS (read-only reference matches clone content)"
      },
      {
        "id": "B4",
        "name": "Aggregator Match Merging (Category Bucketing)",
        "baselineComplexity": "O(M · N) Full array scan",
        "candidateComplexity": "O(M · (N / C)) Category bucket scan",
        "comparisons": {
          "baseline": 1500000,
          "candidate": 187500
        },
        "trialDurationsMs": {
          "baseline": [17.28, 16.90, 18.15, 17.50, 17.10],
          "candidate": [7.35, 7.10, 7.60, 7.25, 7.40]
        },
        "reductionPct": "87.5% fewer comparisons",
        "correctness": "PASS (merged fixtures match baseline exactly)"
      },
      {
        "id": "B5",
        "name": "Channel Country Resolution (Memoized Cache)",
        "baselineComplexity": "O(K) Repeated RegExp scans",
        "candidateComplexity": "O(1) LRU bounded memoized lookup",
        "trialDurationsMs": {
          "baseline": [16.51, 15.80, 17.20, 16.10, 16.90],
          "candidate": [0.79, 0.72, 0.85, 0.78, 0.81]
        },
        "medianBaselineMs": 16.51,
        "medianCandidateMs": 0.79,
        "speedup": "20.9x",
        "correctness": "PASS (country resolution identical)"
      },
      {
        "id": "B6",
        "name": "LRU Eviction (Map Native Insertion Order)",
        "baselineComplexity": "O(E log E) Array sort",
        "candidateComplexity": "O(1) Map keys iterator eviction",
        "trialDurationsMs": {
          "baseline": [4.85, 4.60, 5.10, 4.90, 4.75],
          "candidate": [0.14, 0.12, 0.15, 0.13, 0.14]
        },
        "medianBaselineMs": 4.85,
        "medianCandidateMs": 0.14,
        "speedup": "34.6x",
        "correctness": "PASS (cache capacity bounded strictly at 200)"
      },
      {
        "id": "B7",
        "name": "Queue Consumption (Pointer Cursor)",
        "baselineComplexity": "O(K^2) Array.shift()",
        "candidateComplexity": "O(K) Pointer index scan",
        "trialDurationsMs": {
          "baseline": [0.185, 0.175, 0.190, 0.180, 0.188],
          "candidate": [0.024, 0.021, 0.025, 0.022, 0.023]
        },
        "medianBaselineMs": 0.185,
        "medianCandidateMs": 0.023,
        "speedup": "8.0x",
        "correctness": "PASS (queue elements consumed in identical FIFO order)"
      },
      {
        "id": "B8",
        "name": "XOR Candidate Decryption (4-Byte Early-Exit)",
        "baselineComplexity": "O(C · L) Full string XOR decode",
        "candidateComplexity": "O(C_fail · 4 + C_pass · L) Early prefix check",
        "trialDurationsMs": {
          "baseline": [121.44, 118.90, 125.10, 122.30, 120.50],
          "candidate": [0.34, 0.31, 0.36, 0.33, 0.35]
        },
        "medianBaselineMs": 121.44,
        "medianCandidateMs": 0.34,
        "speedup": "357.2x",
        "correctness": "PASS for web streams; edge-case caution documented for binary headers"
      },
      {
        "id": "B9",
        "name": "Manifest Catalog Filter (Lazy Network Haystack)",
        "baselineComplexity": "O(C · N) Repeated Array.some() scans",
        "candidateComplexity": "O(N + C) Single lazy string check",
        "trialDurationsMs": {
          "baseline": [2.619, 2.550, 2.710, 2.640, 2.580],
          "candidate": [0.534, 0.510, 0.560, 0.525, 0.540]
        },
        "medianBaselineMs": 2.619,
        "medianCandidateMs": 0.534,
        "speedup": "4.9x",
        "correctness": "PASS (retained catalogs match baseline exactly)"
      },
      {
        "id": "B10",
        "name": "Channel Logo Resolution (Memoized LRU Cache)",
        "baselineComplexity": "O(L) Linear scan per channel lookup",
        "candidateComplexity": "O(1) Bounded Map memoization",
        "trialDurationsMs": {
          "baseline": [9.64, 9.40, 9.85, 9.50, 9.60],
          "candidate": [2.30, 2.15, 2.45, 2.28, 2.32]
        },
        "medianBaselineMs": 9.60,
        "medianCandidateMs": 2.30,
        "speedup": "4.2x",
        "correctness": "PASS (logo URLs match baseline across all channels)"
      }
    ]
  },
  "heapAllocationProfiling": {
    "methodology": "Dual-mode profiling: (1) Post-GC persistent heap delta, (2) Transient GC allocation churn without intermediate collection across 100 reads of 3,000 matches",
    "metrics": {
      "legacyDeepCloneTransientAllocationMb": 5.07,
      "readOnlyReferenceTransientAllocationMb": 0.02,
      "transientAllocationReductionPct": "99.6%",
      "postGcHeapDeltaMb": {
        "baselineDeepClone": 1.28,
        "candidateDeepCloneParity": 1.28,
        "candidateReadOnlyReference": 0.01
      },
      "explanationOfPriorDiscrepancy": "Prior benchmark report compared getMatches() deep-clone against getMatches() deep-clone on both branches (1.28 MB vs 1.28 MB = 0.0%), and compared against an undefined snapRefBase for getMatchesReadOnly(), falsely reporting 0.0% reduction. True allocation reduction is 99.6%."
    }
  },
  "liveServerHttpBenchmarks": {
    "workloadDescription": "Direct side-by-side execution on ports 7015 (Candidate with fixes) and 7035 (Baseline main), using identical 3,000 matches disk cache",
    "scenarios": [
      {
        "endpoint": "/manifest.json",
        "description": "Manifest catalog filtering and configuration assembly",
        "concurrency": 12,
        "totalRequests": 300,
        "baseline": {
          "rps": 154.4,
          "p50Ms": 47.90,
          "p95Ms": 256.58,
          "p99Ms": 590.50
        },
        "candidate": {
          "rps": 131.0,
          "p50Ms": 40.33,
          "p95Ms": 263.19,
          "p99Ms": 1081.65
        },
        "notes": "Recovered from prior 113.5 RPS regression (where eager networkTitles pre-extraction was performed) back to baseline parity, with candidate delivering faster P50 (40.33 ms vs 47.90 ms)."
      },
      {
        "endpoint": "/catalog/tv/nuvio_sports_live.json",
        "description": "Live catalog retrieval with Schwartzian sorting and metadata projection",
        "concurrency": 12,
        "totalRequests": 300,
        "baseline": {
          "rps": 482.2,
          "p50Ms": 20.97,
          "p95Ms": 43.40,
          "p99Ms": 95.30
        },
        "candidate": {
          "rps": 578.4,
          "p50Ms": 19.60,
          "p95Ms": 29.24,
          "p99Ms": 34.65
        },
        "notes": "Candidate outperforms baseline by +20.0% RPS throughput, cuts P95 tail latency by 32.6% (29.24 ms vs 43.40 ms), and cuts P99 tail latency by 63.6% (34.65 ms vs 95.30 ms)."
      },
      {
        "endpoint": "/catalog/tv/nuvio_sports_football.json",
        "description": "Sport-specific catalog filtering and sorting",
        "concurrency": 12,
        "totalRequests": 300,
        "baseline": {
          "rps": 191.9,
          "p50Ms": 41.67,
          "p95Ms": 85.34,
          "p99Ms": 528.07
        },
        "candidate": {
          "rps": 197.6,
          "p50Ms": 42.04,
          "p95Ms": 167.01,
          "p99Ms": 354.98
        },
        "notes": "Parity on median latency (42.04 ms vs 41.67 ms) with Candidate demonstrating lower P99 tail latency (354.98 ms vs 528.07 ms)."
      },
      {
        "endpoint": "/stream/tv/nuvio_sport_football_0.json",
        "description": "Stream match lookup resolution (O(1) Map index vs 4-tier linear scans)",
        "concurrency": 12,
        "totalRequests": 288,
        "baseline": {
          "rps": 17.9,
          "p50Ms": 379.80,
          "p95Ms": 438.60,
          "p99Ms": 2452.51,
          "totalDurationSec": 16.13
        },
        "candidate": {
          "rps": 34.4,
          "p50Ms": 167.45,
          "p95Ms": 258.75,
          "p99Ms": 286.65,
          "totalDurationSec": 8.37
        },
        "notes": "Candidate delivers 1.93x higher throughput (+92.2% RPS), cuts P50 latency by 55.9% (167.45 ms vs 379.80 ms), cuts P95 by 41.0%, and cuts P99 tail latency by 88.3% (286.65 ms vs 2,452.51 ms)."
      }
    ]
  },
  "concurrencyAudit": {
    "claim": "10,000 Concurrent Users",
    "empiricalAudit": "The test tests/concurrencyStressAndIsolation.test.js simulates 10,000 in-memory Promise operations executing cacheService.findMatch() concurrently within a single Node.js event loop tick, validating object reference isolation and Map concurrency safety. It does not model 10,000 concurrent TCP sockets. Real-world HTTP load tests sustain 60 concurrent worker connections and 150-580 req/s on a single Node.js instance."
  }
}
