<div dir="ltr">On Sat, Oct 26, 2013 at 9:40 AM, David Nolan <span dir="ltr"><<a href="mailto:dave@textgoeshere.org.uk" target="_blank">dave@textgoeshere.org.uk</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><span style="background-color:rgb(251,251,251);color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:13px;line-height:22px">With a bit of memoization, this one runs pretty fast (2+ times faster than the next fastest on haystacks > 100 chars and needles > 4 chars, and increasingly much better as the strings get larger): </span><a href="https://gist.github.com/knaveofdiamonds/7155189#comment-936910" target="_blank">https://gist.github.com/knaveofdiamonds/7155189#comment-936910</a></div>
<div><div><br></div><div>As an aside, the fruity gem is excellent for benchmarking. This explains why: <a href="https://github.com/marcandre/fruity#approach" target="_blank">https://github.com/marcandre/fruity#approach</a>.</div>
</div></div></blockquote><div><br></div><div>Interesting concept indeed.<br><br></div><div>Also the naive Rspec timing test confirms "dave_spec.rb" to be faster than all other contenders<br></div><div>and fairly memory efficient. I presume the naive Rspec timing test is losing relevance, compared<br>
to more serious Benchmarking tools.<br><br><pre><code>roland_spec.rb => 9.14 s 11 loc (1035 MB max RSIZE)
michael_spec.rb => 8.82 s 13 loc (1044 MB max RSIZE)
peter_spec.rb => 5.91 s 30 loc ( 244 MB max RSIZE)
tom_spec.rb => 20.05 s 9 loc ( 326 MB max RSIZE)
dominic_spec.rb => 395. s 14 loc ( 434 MB max RSIZE)
jason_spec.rb => 16.21 s 19 loc ( 535 MB max RSIZE)
peter2_spec.rb => 5.24 s 42 loc ( 222 MB max RSIZE)
dave_spec.rb => 4.82 s 19 loc ( 323 MB max RSIZE) </code></pre>(ref <a href="https://gist.github.com/petervandenabeele/7161464">https://gist.github.com/petervandenabeele/7161464</a> )<br></div><div><br>Fun !<br>
<br></div><div>Peter<br></div></div></div></div>