Closed p5pRT closed 14 years ago
-----BEGIN PGP SIGNED MESSAGE-----
Moin\,
using BigInt v1.67 or BigInt v1.66 does not matter:
# perl -MBenchmark -Mbigint -le '$a = 123 ** 123; timethese ( -3\, { "blog" => sub { $a->copy()->blog(123) }\, } )' Benchmark: running blog for at least 3 CPU seconds ...
runloop unable to compile 'CODE(0x81d0c48)': Bareword "NaN" not allowed while "strict subs" in use at (eval 31) line 1.
code: sub { for (1 .. NaN) { local $_; package main; &$c; } } at -e line 1
Oops. Whats that?
Best wishes\,
Tels
- -- Signed on Sun Dec 7 23:12:26 2003 with key 0x93B84C15. Visit my photo gallery at http://bloodgate.com/photos/ PGP key on http://bloodgate.com/tels.asc or per email.
"Die deutsche Zensoren - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Dummköpfe - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -." Heinrich Heine
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) Comment: When cryptography is outlawed\, bayl bhgynjf jvyy unir cevinpl.
iQEVAwUBP9OmjncLPEOTuEwVAQG5sQf+Mu+GfDE8DDWCMjPFucHBvdE+fccKXOWO T5djoNUUHBJVo1BpvdqTrIQw2fT+wFxZMPurxucrHKoj1IACAMXXbvMMCh4ay4DG 4yk2nfO5BcundjkjZk7dNHeoujCppnlSnkSzQKUh3yFGKEzPm4MbRt7gHGP7eDBe G7yHE85TYfep/ehL4y6Y3esA50QG7Tr30t/diWOFcwWsPPDx9uFD4Ae9KToBQdWA F5NNWjiKb7A/ZoCysik1yiUAAE6Xt3Y+oJ2LTHaq/eU38yhZ+t0oGDxddEKtc9qy blt7OVm3EDECIkJzM8IGttcLE5o9HmHTcFXMbstCk2hrgTEbiVjHkQ== =4TZ2 -----END PGP SIGNATURE-----
Tels (via RT) \perlbug\-followup@​perl\.org wrote: :using BigInt v1.67 or BigInt v1.66 does not matter: : :# perl -MBenchmark -Mbigint -le '$a = 123 ** 123; timethese ( -3\, { "blog" => :sub { $a->copy()->blog(123) }\, } )' :Benchmark: :running : blog : for at least 3 CPU seconds :... : :runloop unable to compile 'CODE(0x81d0c48)': Bareword "NaN" not allowed while :"strict subs" in use at (eval 31) line 1. : :code: sub { for (1 .. NaN) { local $_; package main; &$c; } } : at -e line 1 : :Oops. Whats that?
I suspect -Mbigint is not compatible with the use of floating point within Benchmark; at line 750: $n = int( $n * ( 1.05 * $tmax / $tc ) ); $tc is 0.1\, but I believe it is getting upgraded to a Bigint 0\, resulting in a division by zero that leaves $n = \inf\, and that is then being interpolated into the '1 .. $n' range in the eval code.
Hugo
-----BEGIN PGP SIGNED MESSAGE-----
Moin\,
On Tuesday 09 December 2003 12:41\, Hugo van der Sanden via RT wrote:
Tels (via RT) \perlbug\-followup@​perl\.org wrote: :using BigInt v1.67 or BigInt v1.66 does not matter: : :# perl -MBenchmark -Mbigint -le '$a = 123 ** 123; timethese ( -3\, { "blog" : => sub { $a->copy()->blog(123) }\, } )' :Benchmark: :running : blog : for at least 3 CPU seconds :... : :runloop unable to compile 'CODE(0x81d0c48)': Bareword "NaN" not allowed : while "strict subs" in use at (eval 31) line 1. : :code: sub { for (1 .. NaN) { local $_; package main; &$c; } } : at -e line 1 :Oops. Whats that?
I suspect -Mbigint is not compatible with the use of floating point within Benchmark; at line 750: $n = int( $n * ( 1.05 * $tmax / $tc ) ); $tc is 0.1\, but I believe it is getting upgraded to a Bigint 0\, resulting in a division by zero that leaves $n = \inf\, and that is then being interpolated into the '1 .. $n' range in the eval code.
The attached patch fixes the problem by converting the input via "$tmax" to a scalar (if it is an Big* object). It also removes the else { } path by clever usage of abs().
I also rewrote the part that prints out little pieces of string (and removed all these nasty "unless $style eq 'none'" bits which made that code hard to read (for me))\, because under -le this results in something like this:
~/perl/benchmark-bigint> perl -I. -MBenchmark -Mbigint -le '$a = 123 ** 123; timethese ( -3\, { "blog" => sub { $a->copy()->blog(123) }\, } )' Benchmark: running blog for at least 3 CPU seconds ...
blog: 3 wallclock secs ( 3.21 usr + 0.00 sys = 3.21 CPU) @ 543.93/s (n=1746)
After the patch you get:
~/perl/benchmark-bigint> perl -I. -MBenchmark -Mbigint -le '$a = 123 ** 123; timethese ( -3\, { "blog" => sub { $a->copy()->blog(123) }\, } )' Benchmark: running blog for at least 3 CPU seconds...
blog: 3 wallclock secs ( 3.20 usr + 0.00 sys = 3.20 CPU) @ 549.38/s (n=1758)
Which is more pleasing to my eye.
I didn't know exactly how to add Benchmark tests reliable\, can somebody point me what to look out for?
RFC: Would it possible to replace the default output of "X wallclock secs" with "Xs"? The overly long output itches me\, but the change might be shot down by the backward-compatible policy....
Best wishes\,
Tels
- -- Signed on Fri Dec 12 19:30:09 2003 with key 0x93B84C15. Visit my photo gallery at http://bloodgate.com/photos/ PGP key on http://bloodgate.com/tels.asc or per email.
"Für eine solche Bitratenreduktion muss ich den Transcoder so umkonfigurieren\, dass er gröbere Quantisierungskoeffizienten für die MPEG-Matrizen verwendet\, Captain" - "An die Arbeit\, Mr. LaForge." -- Jens Baumeister in http://tinyurl.com/oomb
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) Comment: When cryptography is outlawed\, bayl bhgynjf jvyy unir cevinpl.
iQEVAwUBP9oJNHcLPEOTuEwVAQFnUwf+OPe4HPFfj6Wtsn0HfCp6FCuLcgGC1Hmr ElQ34bKUBvkw03Z1FqxomZsqQIJc22jgpmYihkIzAvndkDOsm1mpFjbzWJmUsfyQ 5m2ARbZCE9EqAnFu0qeAtpZhFnhgkyLm1m6hHV0W586s1pon76vRm7PsSTZxuK0r rSFpPa4hx+Rkd5LmdB+NXXL62l2Zi0bIdOQZav4/bvHV2viyp9P4Y5KWcPd8FFAd ZLZn9Idw0nSeAtzXg83H7WH63rFaXcUltgns6OBaZM+I8V+ErnN92yNhKWpvqIri 8aq3rNqFla4Td2A4ilpjQbjoDCZ2HYNmho1eyErOEXbhynwNcrqITA== =RSl6 -----END PGP SIGNATURE-----
Tels \perl\_dummy@​bloodgate\.com wrote: :On Tuesday 09 December 2003 12:41\, Hugo van der Sanden via RT wrote: :> I suspect -Mbigint is not compatible with the use of floating point within :> Benchmark : :The attached patch fixes the problem by converting the input via "$tmax" to a :scalar (if it is an Big* object). It also removes the else { } path by clever :usage of abs().
I am very dubious about modifying something like Benchmark to cope with -Mbigint's way of modifying what perl does - it is perfectly reasonable for any normal module to assume it can assign a floating-point value to a number without it being converted to an integer.
A more supportable direction to progress would perhaps be to introduce a way to restrict the effect of 'use bigint' to a lexical scope. I feel that would make bigint more useful in general\, and make it much easier to combine with external libraries without having to rewrite each one to get cleverer (and less perlish) about its use of floating point.
The other changes might well be desirable: I've found the output of timethese() much less readable since previous patches extended the output beyond 80 characeters\, and I think it should be sufficient to explain the output in the documentation without having to spell out 'wallclock seconds' every time.
Hugo
-----BEGIN PGP SIGNED MESSAGE-----
Moin\,
On Saturday 13 December 2003 12:59\, hv@crypt.org wrote:
Tels \perl\_dummy@​bloodgate\.com wrote: :On Tuesday 09 December 2003 12:41\, Hugo van der Sanden via RT wrote: :> I suspect -Mbigint is not compatible with the use of floating point :> within Benchmark : :The attached patch fixes the problem by converting the input via "$tmax" : to a scalar (if it is an Big* object). It also removes the else { } path : by clever usage of abs().
I am very dubious about modifying something like Benchmark to cope with -Mbigint's way of modifying what perl does - it is perfectly reasonable for any normal module to assume it can assign a floating-point value to a number without it being converted to an integer.
A more supportable direction to progress would perhaps be to introduce a way to restrict the effect of 'use bigint' to a lexical scope. I feel that would make bigint more useful in general\, and make it much easier to combine with external libraries without having to rewrite each one to get cleverer (and less perlish) about its use of floating point.
You are very probably right. The patch was an easy solution. use bigint; should work like use integer; - however\, I have currently no time/energy to rewrite it. I can put it on my TODO\, but it might be there forever....
However\, one more comment:
te@null:\~> perl -I. -MBenchmark -MMath::BigInt -le '$a = Math::BigInt->new(123) ** 123; timethese ( Math::BigInt->new(-3)\, { "blog" => sub { $a->copy()->blog(123); }\, } )' Benchmark: running blog for at least 3 CPU seconds...
runloop unable to compile 'CODE(0x81d0548)': Bareword "NaN" not allowed while "strict subs" in use at (eval 18) line 1.
code: sub { for (1 .. NaN) { local $_; package main; &$c; } } at -e line 1
I think because Benchmark and BigInt are both core modules\, and benchmark is widely used\, it should also cope with BigInt inputs to it's subroutines. Especially when the change is so small and simple. However\, I can see your point in not special casing it.
The other changes might well be desirable: I've found the output of timethese() much less readable since previous patches extended the output beyond 80 characeters\, and I think it should be sufficient to explain the output in the documentation without having to spell out 'wallclock seconds' every time.
\
One more point that really annoys me: The default output is to two digits after the dot (1.23\, 1234.56\, 123456.78). This doesn't really make sense\, because it implies an accuracy that really cannot be achieved (12345.67 implies the result is accurate to 7 digits). Something like "12340" would be probably better (e.g. max 4 digits accuracy). Of course\, output like "0.28" would stay "0.28". That would also shorten the output a bit.
Attached is a patch to:
* make perl -MBenchmark -le more pleasing as by my first patch * replace the "wallclock secs" by "s" * adjusts the expected test output
All tests successful. u=2.36 s=0.45 cu=135.09 cs=13.7 scripts=789 tests=78632
Cheers\,
Tels
- -- Signed on Sat Dec 13 13:02:17 2003 with key 0x93B84C15. Visit my photo gallery at http://bloodgate.com/photos/ PGP key on http://bloodgate.com/tels.asc or per email.
"We have problems like this all of the time\," Kirk said\, trying to reassure me. "Sometimes its really hard to get things burning." -- http://tinyurl.com/qmg5
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) Comment: When cryptography is outlawed\, bayl bhgynjf jvyy unir cevinpl.
iQEVAwUBP9sIo3cLPEOTuEwVAQE9pAf/QthAM2LoFMLOjhzTDZ9yO5hQWWDGab8Y oR5gaXEWhfHCVypH3pM2cJXwUfJ0AqWH2zsHF90RjE+PVheFcltNnJEDi+FKlA6v 1Wrc+74CEfM5uyGEcn88fy5VsfGMHw+h+BRNNGoplfX0C42gsXU5qanLmKfCDJB8 q7/dU+ORJ2W5r8O8XG05lneBM2FcqA9XXdn/Uv05BfN9aGdI7VdUjWvxmbQFkjXq R+Bb/FnCBzJLHw5ry1z4Vhm8fpThJqtHg+O5DxRKZhY3t7GzMUbSx12EO80Q4Caj bAWePrLW/172tnfSr6v+8oLpF806JAKdMhqyar5qCkt6rUSQidqRyA== =v0+N -----END PGP SIGNATURE-----
Tels wrote:
A more supportable direction to progress would perhaps be to introduce a way to restrict the effect of 'use bigint' to a lexical scope. I feel that would make bigint more useful in general\, and make it much easier to combine with external libraries without having to rewrite each one to get cleverer (and less perlish) about its use of floating point.
You are very probably right. The patch was an easy solution. use bigint; should work like use integer; - however\, I have currently no time/energy to rewrite it. I can put it on my TODO\, but it might be there forever....
I expect that when lexical pragmas will be fixed\, we'll make a pass on all pragmas\, and that you may receive a patch :)
I’m marking this as resolved\, as bigint is lexical now.
@cpansprout - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#24622 (status was 'resolved')
Searchable as RT24622$