This example illustrates an additional point about algorithmic efficiency.
BrowserUk had initially thought that the algorithm wasn't quadratic because it didn't look quadratic in runs of 10, 100, and 1000 elements. But it did look quadratic when he tested 10_000 and 100_000.
The reason is that the quadratic piece all consists of copying pointers in C, which is very fast. You do a lot of it, so it doesn't scale, but for small sample sizes the eventual performance bottleneck is invisible. And then once the performance bottleneck becomes visible, it doesn't take long until it dominates.
Which is a basic fact about scalability. When you are dealing with small samples, you care much more about the efficiency of your individual operations. Which is relatively easy to benchmark. When you deal with large samples, you care about the scaling pattern. A very cheap operation that is at a spot which scales poorly will eventually be a bottleneck. Understanding the latter kind of problem is fairly hard for most people, and problems of this nature constantly tend to surprise people who didn't factor it in in a simple extrapolation.
(Important note: scaling bottlenecks don't just happen in code. If you spend most of your life in meetings, well you've just seen what a scaling bottleneck in an organization of humans looks like!)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||