Have you tried benchmark?
I can only benchmark algorithms when I have more than one algorithm to
compare.
I only thought of the one algorithm that I mentioned in my original
post, and so
I had nothing to benchmark it against.
I can easily do the benchmarking, and I was not asking anyone to do it
for me.
I wrote my email because I was looking for algorithm suggestions, such
as the third
one that you mentioned. I was previously unaware of 'each_byte'. I
also didn't
think of trying the split('') version.
Sorry, didn't mean to imply anything. I just had wanted to show the
performance of the obvious ways I knew (as I couldn't think of anything
smarter).
Thank you for these suggestions.
BTW, I also tried Simon's Iterator::Reverse (about 13 seconds) and an
explicit idx-- type loop (about 3 seconds). I just wanted to show that
the reverse.each_byte (as explained by Joel) creates less objects and
seems fastest. Sorry for not making myself clear
"Mehr, Assaph (Assaph)" <assaph@avaya.com> writes:
[ ... ]
Sorry, didn't mean to imply anything. I just had wanted to show the
performance of the obvious ways I knew (as I couldn't think of anything
smarter).
Well, I too am sorry: for having misinterpreted the intent of your
message. That's one of the hazards of communicating in writing.
Without our being able to see each other's facial expressions or hear
each other's tone of voice, sometimes these temporary misunderstandings
occur.
Thank you for these suggestions.
BTW, I also tried Simon's Iterator::Reverse (about 13 seconds) and an
explicit idx-- type loop (about 3 seconds). I just wanted to show that
the reverse.each_byte (as explained by Joel) creates less objects and
seems fastest. [ ... ]
Yes, that does indeed seem fastest of the algorithms mentioned so far.
And now, if only there were a String#reverse_each_byte ... so I can
avoid the 'reverse' altogether.
[ ... ] Sorry for not making myself clear
And I'm sorry for not correctly interpreting your words.
So all is well.
And thanks again.
ยทยทยท
--
Lloyd Zusman
ljz@asfast.com
God bless you.