Compile Ruby code?
-
From http://code.google.com/intl/nb/apis/sketchup/docs/faq.html - "My script is slow. How can I improve performance?"
@unknownuser said:
Use a compiled Ruby extension module to do the work in compiled code.
How do you do that?
-
you don't compile Ruby code, you need to write the code in C (or other language that creates a DLL on Windows). take a look at http://www.rubyinside.com/how-to-create-a-ruby-extension-in-c-in-under-5-minutes-100.html
-
Ah. I had seen some .so files some times and I thought maybe these where "compiled ruby scripts".
-
@unknownuser said:
you don't compile Ruby code, you need to write the code in C (or other language that creates a DLL on Windows)
What about Mac? Is it more complicated?
-
@unknownuser said:
What about Mac? Is it more complicated?
if you don't use Windows specific code than you just compile for Mac and done. in the article it said "this was all tested on OS X"
-
But before you go down the C++ route, I'd really suggest looking carefully at your Ruby and ensuring its as fast as it can be.
Make sure you're not creating lots of objects. Make sure you cache intermediate results. Make sure you don't use the fancy Ruby expressions for loops which are slow. Make sure you avoid at all costs any Struct stuff which is insanely slow.
And on..Adam
-
@adamb said:
Make sure you don't use the fancy Ruby expressions for loops which are slow.
Which are these?
@adamb said:
Make sure you avoid at all costs any Struct stuff which is insanely slow.
Structs?
I'm not planning on compiling C++ stuff, not my cup of tea. I was just curious about this "compiled ruby" stuff.
-
@unknownuser said:
take a look at http://www.rubyinside.com/how-to-create-a-ruby-extension-in-c-in-under-5-minutes-100.html
I am on completely unknown territory and have stopped on the 'make' command.
I presume it is the command responsible for compiling the C code with the makefile created in a previous step.I would like to recreate the MyTest in VC++ 2008 Express Edition... and I am lost. I will dig through internet to understand the whole process, but if someone can explain me in few words how to compile the example with VC++2008 will be thankful.
Tomasz
Advertisement