It’s like reading the dictionary - you may have all the words, but a normal block of text is going to have some words a lot (“a,” “the,” “monkey”) and some words almost never (“proprioceptive,” “batrachian,” “fustian.”) That’s because they’re each written to test one feature, but not set up according to which features are used the most, or in what combination. If you get lots of them together (example: Ruby’s benchmarks directory) then it still won’t tell you much. If you want to know how fast Ruby is overall, a microbenchmark won’t tell you much. Microbenchmarks: ProblemsĪ good microbenchmark measures one small, specific thing. You don’t do much setup, and it doesn’t usually take long to run. each loop, an Integer plus or a map) a microbenchmark can measure that very exactly while measuring almost nothing else.Ī well-tuned microbenchmark can often detect very tiny changes, especially when running many iterations per step (see “Writing Good Microbenchmarks” below.) If you see a result like “this optimization speeds up Ruby loops by half of one percent", you’re pretty certainly looking at the result of a microbenchmark.Īnother advantage of running just one small piece of code is that it’s usually easy and fast. If you want to see how fast a particular tiny Ruby operation is (e.g. The code being timed is generally tiny, simple and specific.Įach one is a perfect example of a microbenchmark: it tests very little code, sometimes just a single Ruby operation. The Ruby language has a bunch of microbenchmarks that ship right in the language - a benchmarks directory that’s a lot like a test directory, but for speed. The easiest size of benchmark to talk about is a very small benchmark, or microbenchmark. Knowing what can go wrong in benchmarks is like learning to spot bad statistics: it’s not easy, but some practice and a few useful principles can help you out a lot. But you may prefer to read it because you use benchmarks for Ruby - if you read the results or run them. I talk about this because I write benchmarks for Ruby. Along the way, we’ll talk about benchmarks that are not microbenchmarks and how to pick a scale/size for a specific benchmark. I’ve mentioned a few times recently that something is a “microbenchmark.” What does that mean? Is it good or bad?
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |