[racket] Efficiency of tight loops in Racket
And it is easy to drop down to the C level with Eli's FFI.
On Jan 13, 2011, at 5:54 PM, Robby Findler wrote:
> It is going to be hard to beat C. My experience is that on tight
> nested loops like that where the loop body is simple and you write the
> loop carefully you can get with 3x of C (or 2x since Matthew has
> improved things since I last tried) but it is difficult to get to that
> point.
>
> Of course, if you want to actually write a real program around your
> loop, then Racket is definitely a good choice. Also, if your loop is
> parallelizable, you might want to try using futures.
>
> In any case, a lot of these little core loops don't take too much time
> to write, so you might try writing it a few times in a few languages
> to see what you see.
>
> Robby
>
> On Thu, Jan 13, 2011 at 4:07 PM, Harry Spier <harryspier at hotmail.com> wrote:
>> Dear list members,
>>
>> I am developing an OCR application. If written in an imperative language (
>> C for example) it would spend most of its time traversing a 2 dimensional
>> array. (I'm representing a black and white page of text as a rectangle of
>> 0's and 1's). My first idea was to prototype in Ruby and then convert to C
>> or to develop in Ruby with C extensions, but I'm wondering if I could do the
>> whole development in Racket. I've seen somewhere (though I can't remember
>> where) that Racket can be in the same order of efficiency as C .
>>
>> But the crux issue is the efficiency of traversing the 2 dimensional array.
>> I've noticed in the Racket Guide section 18.7 "Unchecked, Unsafe
>> Operations" where it says "For tight loops that use these functions,
>> avoiding checks can sometimes speed the computation, though the benefits
>> vary for different unchecked functions and different contexts."
>>
>> Have any list members ever compared the efficiency of nested C loops and how
>> you would traverse a 2 dimensional array in Racket.
>>
>> Thanks in advance,
>> Harry Spier
>>
>>
>> _________________________________________________
>> For list-related administrative tasks:
>> http://lists.racket-lang.org/listinfo/users
>>
> _________________________________________________
> For list-related administrative tasks:
> http://lists.racket-lang.org/listinfo/users