From: Jan Dvorak Date: 2008-04-17T07:29:08+09:00 Subject: Re: Ruby Opengl Speed On Wednesday 16 April 2008 23:44:51 Diego Bernardes wrote: > Ruby has a Opengl binding, but well, its kind slow compared to c or > java, this is because of the language or the binding? If ruby get more > fast the overall performance gonna increase? or the bottleneck its the > binding? In short: language and/or interpreter is the bottleneck. The OpenGL API is mostly straightforward, and while ruby-opengl bindings do additional state checks, most functions just boils down to: 1. convert data between ruby a C types (simple shift for Fixnum, pointer access for Float) 2. call OpenGL function 3. convert return parameter the same way (most OpenGL function does not return anything) The overhead is fairly small, to the point that when in ruby-opengl 0.60 we added glGetError() call (and raise on error) after each OpenGL function call, there was no measurable slowdown. With ruby 1.9 the bindings are about 2x-5x faster than with ruby1.8, and basically the performance is the same as Perl's POGL bindings (as measured by trislam benchmark), and few times faster than Python's. That is probably as fast as it gets with interpreted languages. Of course when you talk about fast/slow, you need to put that in context - computing all data on CPU and calling glVertex* milion times will be always *much* slower than in C (or Java), but does that mean anything ? If it's possible to offload anything on GPU, do it. With today's videocards with SM4.0 and all, it is possible to write applications where the CPU is not bottleneck, and so they can be as fast as if written in C/Java. Jan