Posté par krapule le 03 août 2011 à 09:59. En réponse à la dépêche Évolutions techniques de systemd. Évalué à 3.
Merci pour cet article bien écrit, très didactique et fort instructif !
Posté par krapule le 07 juillet 2010 à 17:18. En réponse au journal Javascript plus rapide que python ! (une suite possible). Évalué à 2.
# très bon article !
Posté par krapule . En réponse à la dépêche Évolutions techniques de systemd. Évalué à 3.
Merci pour cet article bien écrit, très didactique et fort instructif !
# code perl - + benchmarks
Posté par krapule . En réponse au journal Javascript plus rapide que python ! (une suite possible). Évalué à 2.
(En bouclant 100 fois)
C (gcc -O3 toto2.c; time ./toto2 >out ) 0.017s 1
lisp (toto4.lisp with loop) 0.037 2
perl (time ./toto2.pl >out2 1.566s 92
python (time python toto2_with_loop.py ) 1.807s 106
toto2.pl
#! /usr/bin/env perl
use strict;
use warnings;
my $NB_ENTRIES = 10000;
my $NB_LOOPS = 100;
test() foreach ( 1..$NB_LOOPS);
sub test {
my @d = (1)x $NB_ENTRIES;
my $mid = int($NB_ENTRIES / 2);
my ($i, $j);
for ($i = 2; $i < $mid; $i++) {
for ($j = $i*2; $j < $NB_ENTRIES; $j += $i) {
$d[$j] += $i;
}
}
my $di;
for ($i = 0; $i < $NB_ENTRIES; $i++) {
$di = $d[$i];
print "$i $di\n" if $di < $NB_ENTRIES && $d[$di] == $i && $i <= $di;
}
}