From: Mathieu Bouchard Date: 2001-05-08T04:45:18+09:00 Subject: [ruby-talk:14805] Re: Why's Ruby so slow in this case? On Mon, 7 May 2001, Stefan Matthias Aust wrote: > >In Ruby, cases _have_ to be tested sequentially, unlike C, which allows > >integers only, and can optimize situations like this using a static array > >of gotos. > I don't think, the case/when stuff was responsible for the slowdown. > It's just that a few milliseconds on each of the some 100_000 calls > eventually sum up. When you *do* remove the profiler, then case/when should become much more important. > >Those seem to be almost-unnecessary abstractions. I would be quite tempted > >to eliminate them. > Well, I disagree. Readably should always come first. Yeah, I think so too. But this abstraction, IMHO, is not enough of an improvement on the unabstracted version. If it were used in more places in the module, or if the expression was more complex, I'd say otherwise. > PS: I like that benchmark module. Why isn't it part of the standard > distribution? I don't know. By the way, some processors have an internal clock, for example a 64-bit CPU-tick number. This clock is across all processes, but OTOH you don't have to ask the kernel at all, and it's so much more precise, so it would be more transparent. So I think this tradeoff would be worthwhile. I presume I could write a very short module that does it for the i586. matju