Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #3613
| From | Brian Candler <b.candler@pobox.com> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Re: float precision |
| Date | 2011-04-28 03:04 -0500 |
| Organization | Service de news de lacave.net |
| Message-ID | <6a573846f8c628a3ba44998931503b96@ruby-forum.com> (permalink) |
| References | (2 earlier) <Hbzyk.36400$Mh5.1689@bgtnsc04-news.ops.worldnet.att.net> <b7499cfe-f5a8-4245-9504-970bdccb0148@i76g2000hsf.googlegroups.com> <9e3fd2c80809160355r323f6beeqd953d5ccfb06758c@mail.gmail.com> <4fa64434d7ba9283414f65a68d0837e9@ruby-forum.com> <d8b1a7254598249b0ae543fb5672545e@ruby-forum.com> |
Joshua S. wrote in post #995421:
> Not surprisingly, it's extremely quicker to convert to a string and
> match a regular expression.
>
> user system total real
> spf : 1.560000 0.000000 1.560000 ( 1.557252)
> *100 : 0.320000 0.000000 0.320000 ( 0.322573)
> *.01 : 0.350000 0.000000 0.350000 ( 0.343289)
> regex: 0.000000 0.000000 0.000000 ( 0.000019)
You should be suspicious of a result which indicates it's 5 orders of
magnitude faster.
> r.report('regex:') {
> f4 = float.to_s.match(/(^-?\d+(\.\d{1,2})?)/)[1].to_f
> }
Ahem, you forgot the "times.times do...end" loop in the benchmark :-)
--
Posted via http://www.ruby-forum.com/.
Back to comp.lang.ruby | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: float precision "Joshua S." <joshsuggs@gmail.com> - 2011-04-27 17:32 -0500
Re: float precision Brian Candler <b.candler@pobox.com> - 2011-04-28 03:04 -0500
Re: float precision "Joshua S." <joshsuggs@gmail.com> - 2011-04-28 12:37 -0500
csiph-web