Artifact b17c352c6bc7650a64286cd7fe8d213bcf438e6c2d3596a706f7f2797953cf63:
- File typeparse/exemples/crible/autres/crible.php — part of check-in [c8a247a331] at 2026-11-26 10:32:15 on branch tip-764_tcl90 — - A strided slice of a compact list filled with a single value is validated and encoded once, then copied cell to cell (TclCompactFillFrom). Sieve, 10^6 bytes: 99 -> 2.2 ms; 9 ms total. - exemples/crible: comparison with C, JavaScript, Python, PHP, Ruby, Perl - type repeat T N ?value?: a list of T made of N times the value (zero by default), in cells without an intermediate list (one million bytes: 0.1 ms); test t131 - direct sum of s + $v over integer cells (8, 16, 32 bits) when no partial sum can exceed 64 bits; test t132 (sieve, 10^6 bytes: counting 2.8 -> 0.2 ms, 2.5 ms total) (user: Florentis, size: 473) [annotate] [blame] [check-ins using]
<?php $N=1000000; function best($f){$b=1e18;$r=null;for($i=0;$i<5;$i++){$t=hrtime(true);$r=$f();$d=(hrtime(true)-$t)/1e6;if($d<$b)$b=$d;}return [$b,$r];} [$tc,$s]=best(fn()=>array_fill(0,$N,1)); [$tk,$s2]=best(function()use($s,$N){$a=$s;$a[0]=$a[1]=0;for($i=2;$i*$i<$N;$i++)if($a[$i])for($j=$i*$i;$j<$N;$j+=$i)$a[$j]=0;return $a;}); [$tn,$r]=best(fn()=>array_sum($s2)); printf("%-32s %7.1f %7.1f %7.1f %7.1f -> %d\n","PHP 8.3 tableau + boucle",$tc,$tk,$tn,$tc+$tk+$tn,$r);