PageSourceSearch

https://chessbook.com/_build/assets/StockfishStressTest-V90Kvdk0.js

js chessbook.com collected 2026-10-03 23:51:50 UTC 8,941 bytes, 1 lines download raw bytes

1(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`chessbook-web@8cada333a37d47d6202c119e56d2497560f13100`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`4551cf65-04a4-40b5-bd52-621af376c957`,e._sentryDebugIdIdentifier=`sentry-dbid-4551cf65-04a4-40b5-bd52-621af376c957`)}catch{}})();import{B as e,E as t,O as n,P as r,S as i,c as a,j as o,l as s,m as c,o as l,v as u}from"./web-pV0rwjaF.js";import{g as d,s as f}from"./index-D5Gq11sO.js";import{Dt as p,Et as m,Tt as h}from"./inner_app-BWThwd46.js";var g=`rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -`,_=`rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3`,v=`rnbqkbnr/pppppppp/8/8/3P4/8/PPP1PPPP/RNBQKBNR b KQkq d3`,y=`rnbqkbnr/pppppppp/8/8/8/5N2/PPPPPPPP/RNBQKB1R b KQkq -`,b=`rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq -`,x=`r1bqkbnr/pppp1ppp/2n5/4p3/2B1P3/5N2/PPPP1PPP/RNBQK2R b KQkq -`,S=`rnbqkbnr/ppp1pppp/8/3p4/4P3/8/PPPP1PPP/RNBQKBNR w KQkq -`,C=`rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq -`,w=`rnb1kbnr/pppp1ppp/8/4p3/6Pq/5P2/PPPPP2P/RNBQKBNR w KQkq -`,T=`7k/5K2/6Q1/8/8/8/8/8 b - -`,E=1e4,D=3e4,O=20,k=3,A=[g,_,v,y,b,x,S,C],j=[`8/8/8/8/8/8/8/8 w - -`,`8/8/8/8/8/8/8/4K2k w - - extra`,`4k3/8/8/8/8/8/8/4K2K w - -`,`4k3/8/8/8/8/8/8/4K3 x - -`,`4k3/8/8/8/8/8/8/4K3 w KK -`,`4k3/8/8/8/8/8/8/4K3 w - e4`,`4k3/8/8/8/8/8/8/P3K3 w - -`,`4k3/8/8/8/8/8/8/9K w - -`,`4k3/8/8/8/8/8/8/11K w - -`,`4k3/8/8/8/8/8/8/4K2z w - -`,`8/8/8/8/8/8/4k3/4K3 w - -`],M=class extends Error{constructor(e){super(`Timed out after ${e}ms`),this.name=`StockfishStressTimeoutError`}},N=(e,t)=>{if(!e)throw Error(t)},P=e=>{N(!!e,`Expected a Stockfish evaluation`),N(Number.isFinite(e.eval)||!!e.mate,`Expected centipawn or mate evaluation`)},F=e=>{N(e.length>=1,`Expected at least one MultiPV move`),N(e.every(e=>e.san&&e.multipv>=1&&e.final),`Expected final SAN moves with MultiPV indexes`),N(new Set(e.map(e=>e.multipv)).size===e.length,`Expected unique MultiPV indexes`)},I=async(e,t)=>{try{await e()}catch{return}throw Error(t)},L=async(e,t,n,r)=>{let i=performance.now(),a;try{await Promise.race([t(),new Promise((e,t)=>{a=setTimeout(()=>t(new M(n)),n)})]);let o={name:e,status:`pass`,durationMs:Math.round(performance.now()-i)};return r?.(o),o}catch(t){t instanceof M&&(h.setupForNewTask(),h.reloadStockfish());let n={name:e,status:`fail`,durationMs:Math.round(performance.now()-i),details:t instanceof Error?t.message:String(t)};return r?.(n),n}finally{a&&clearTimeout(a)}},R=async({nodes:e=E,caseTimeoutMs:t=D,burstSize:n=O,reloadCycles:r=k,includeReloadRecovery:i=!1,onCaseResult:a}={})=>{let o=[],s=new Date().toISOString(),c=async(e,n)=>{o.push(await L(e,n,t,a))};await c(`rejects malformed EPD corpus before engine analysis`,async()=>{for(let e of j)await I(()=>m(e),`Invalid EPD was accepted: ${e}`);m(g)}),await c(`rejects invalid request options before engine analysis`,async()=>{await I(()=>h.getTopMoves(g,{pv:0,nodes:e}),`Invalid MultiPV was accepted`),await I(()=>h.evalPos({epd:g,nodes:0}),`Invalid node count was accepted`),await I(()=>h.evalPos({epd:g,nodes:100000001}),`Oversized node count was accepted`)}),await c(`evaluates a normal legal position`,async()=>{P(await h.evalPos({epd:g,nodes:e}))}),await c(`rejects invalid inputs while queued work is active`,async()=>{let t=h.evalPos({epd:g,nodes:e+1});await Promise.all(j.slice(0,4).map(t=>I(()=>h.evalPos({epd:t,nodes:e+2}),`Invalid EPD was accepted during active work: ${t}`))),P(await t)}),await c(`serializes queued evaluation requests`,async()=>{let[t,n]=await Promise.all([h.evalPos({epd:g,nodes:e}),h.evalPos({epd:_,nodes:e})]);P(t),P(n)}),await c(`serializes a large unique-node evaluation burst`,async()=>{let t=await Promise.all(Array.from({length:n},(t,n)=>{let r=A[n%A.length];return h.evalPos({epd:r,nodes:e+10+n})}));N(t.length===n,`Expected ${n} queued evaluations, got ${t.length}`),t.forEach(P)}),await c(`serializes a mixed eval and MultiPV request burst`,async()=>{let[t,n,r,i]=await Promise.all([h.evalPos({epd:g,nodes:e}),h.getTopMoves(_,{pv:2,nodes:e}),h.evalPos({epd:v,nodes:e}),h.evalPos({epd:y,nodes:e})]);P(t),P(n.evaluation),P(r),P(i),N(n.moves.length>=1,`Expected queued MultiPV request to return moves`)}),await c(`alternates MultiPV settings across queued requests`,async()=>{let[t,n,r,i,a]=await Promise.all([h.getTopMoves(g,{pv:1,nodes:e+40}),h.getTopMoves(_,{pv:5,nodes:e+41}),h.evalPos({epd:b,nodes:e+42}),h.getTopMoves(x,{pv:2,nodes:e+43}),h.getTopMoves(g,{pv:10,nodes:e+44})]);F(t.moves),F(n.moves),P(r),F(i.moves),F(a.moves),N(a.moves.length<=10,`Expected max MultiPV request to cap at 10 moves`)}),await c(`returns final MultiPV move data`,async()=>
1{let t=await h.getTopMoves(g,{pv:3,nodes:e});P(t.evaluation),F(t.moves)}),await c(`handles repeated checkmate and stalemate without engine search`,async()=>{let t=await h.evalPos({epd:w,nodes:e});N(t?.mate?.[0]===0&&t.mate[1]===`black`,`Expected black mate`);let n=await h.getTopMoves(T,{pv:3,nodes:e});N(n.moves.length===0,`Expected no legal moves in stalemate`),N(n.evaluation.eval===0,`Expected stalemate to evaluate as 0`),N((await Promise.all(Array.from({length:8},(t,n)=>n%2==0?h.evalPos({epd:w,nodes:e}):h.getTopMoves(T,{pv:3,nodes:e})))).length===8,`Expected all terminal requests to resolve`)}),i&&await c(`recovers after repeated engine reloads`,async()=>{for(let t=0;t<r;t+=1)p(),P(await h.evalPos({epd:A[t%A.length],nodes:e+80+t}))});let l=o.filter(e=>e.status===`pass`).length,u=o.length-l;return{startedAt:s,finishedAt:new Date().toISOString(),passed:l,failed:u,cases:o}},z=t(`<main class="min-h-screen bg-white text-slate-950"><div class="mx-auto flex w-full max-w-4xl flex-col gap-6 px-5 py-8"><div class="flex flex-col gap-3 border-b border-slate-200 pb-5 sm:flex-row sm:items-end sm:justify-between"><div><h1 class="text-2xl font-semibold">Stockfish Stress Test</h1><p class="mt-1 text-sm text-slate-600">Shared engine contract checks for web, iOS, and Android.</p></div><button class="h-10 rounded bg-slate-950 px-4 text-sm font-medium text-white disabled:cursor-not-allowed disabled:bg-slate-400"></button></div><div class="overflow-hidden border border-slate-200"><div class="grid grid-cols-[96px_1fr_96px] border-b border-slate-200 bg-slate-50 px-3 py-2 text-xs font-semibold uppercase tracking-wide text-slate-600"><span>Status</span><span>Case</span><span class=text-right>Duration`),B=t(`<div class="grid grid-cols-2 gap-3 sm:grid-cols-4"><!><!><!><!>`),V=t(`<p class="px-3 py-4 text-sm text-slate-600">Run the suite to see results.`),H=t(`<p class="mt-1 break-words text-xs text-red-75">`),U=t(`<div class="grid grid-cols-[96px_1fr_96px] gap-3 border-b border-slate-100 px-3 py-3 text-sm last:border-b-0"><span></span><div class=min-w-0><p class="font-medium text-slate-900"></p></div><span class="text-right text-slate-600">ms`),W=t(`<div class="border border-slate-200 px-3 py-2"><div class="text-xs font-medium uppercase tracking-wide text-slate-500"></div><div class="mt-1 text-sm font-semibold text-slate-950">`),G=()=>{let[t,a]=e(!1),[p,m]=e([]),[h,g]=e(null),_=async()=>{if(!t()){a(!0),m([]),g(null);try{let e=await R({includeReloadRecovery:new URLSearchParams(window.location.search).get(`reload`)===`1`||f,onCaseResult:e=>m(t=>[...t,e])});g(e),document.body.dataset.stockfishStressStatus=e.failed===0?`pass`:`fail`,window.__stockfishStressResult=e,console.log(`[stockfish-stress-result]`,JSON.stringify(e))}finally{a(!1)}}};d(()=>{(new URLSearchParams(window.location.search).get(`autorun`)===`1`||f)&&_()});var v=z(),y=v.firstChild,b=y.firstChild,x=b.firstChild.nextSibling,S=b.nextSibling;return S.firstChild,x._$$click=_,c(x,()=>t()?`Running...`:`Run suite`),c(y,r(o,{get when(){return h()},children:e=>(()=>{var t=B(),n=t.firstChild,i=n.nextSibling,a=i.nextSibling,o=a.nextSibling;return c(t,r(K,{label:`Passed`,get value(){return e().passed.toString()}}),n),c(t,r(K,{label:`Failed`,get value(){return e().failed.toString()}}),i),c(t,r(K,{label:`Started`,get value(){return new Date(e().startedAt).toLocaleTimeString()}}),a),c(t,r(K,{label:`Finished`,get value(){return new Date(e().finishedAt).toLocaleTimeString()}}),o),t})()}),S),c(S,r(o,{get when(){return p().length>0},get fallback(){return V()},get children(){return r(n,{get each(){return p()},children:e=>(()=>{var t=U(),n=t.firstChild,i=n.nextSibling,a=i.firstChild,d=i.nextSibling,f=d.firstChild;return c(n,()=>e.status),c(a,()=>e.name),c(i,r(o,{get when(){return e.details},get children(){var t=H();return c(t,()=>e.details),t}}),null),c(d,()=>e.durationMs,f),s(()=>u(e.status===`pass`?`font-semibold text-emerald-700`:`font-semibold text-red-75`),(e,t)=>{l(n,e,t)}),t})()})}}),null),s(()=>t(),e=>{i(x,`disabled`,e)}),v},K=e=>(()=>{var t=W(),n=t.firstChild,r=n.nextSibling;return c(n,()=>e.label),c(r,()=>e.value),t})();a([`click`]);export{G as StockfishStressTest};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.