Hello! Benchmarks are idiosyncratic and devious and I thank you for starting a comparison whose results interest me greatly. =]
On Tue, 2003-02-18 at 10:03, Tupshin Harper wrote: > [...]and some are in languages I am less then fluent in > (last touched any flavor of assembly in 1985, and barely touched it > then), so be kind. I don't believe I'm being too unfair to any of the > languages, though feel free to tell me otherwise. I looked at the .pl and .py versions and was struck by the very dissimilar approaches taken in the two. I translated the GOTO-style primes.pl to a loop syntax in both Perl and Python which I believe accurately represents the logic of primes.pasm without resorting to actual GOTO statements[1]. I'd be very curious as to the runtime of these on the system you used for the earlier benchmarks. On my box, the retooled Python script takes only approximately 50% of the time used by the earlier Perl version; the retooled Perl version runs in roughly 30% the time of its Perl predecessor. Thanks again for taking this initiative! --j [1] "Go To Statement Considered Harmful", Edsger W. Dijkstra, Communications of the ACM, Vol. 11, No. 3, March 1968, pp. 147-148; see http://www.acm.org/classics/oct95/ -- Jim Meyer, Geek at Large [EMAIL PROTECTED]
#!/usr/bin/env perl my $i1 = 1; my $i2 = 10000; printf("\nThe primes up to %d are:\n", $i2); while ($i1 <= $i2) { my $i3 = 2; my $i4 = $i1 / 2; while (1) { if ($i1 % $i3) { $i3++; next if ($i3 <= $i4); print "$i1\n"; } last; } $i1++; }
#!/usr/bin/env python2 i2 = 10000 print "\nThe primes up to %d are:" % i2 for i1 in range(1,i2+1) : i3 = 2 i4 = i1 / 2 while 1: if i1 % i3: i3 += 1 if i3 <= i4 : continue print i1 break