C API or RUBY API

Hi all,

I need to export the outliner (the tree) of component and group with tag with API.
Is C faster than Ruby ?

Is C able to read attribute and length of entities ?

Thanks for your answer

Yes. C code is compiled. Ruby code is interpreted at runtime.

Yes. See the online C API docs …

Yes, but it might not be significantly faster. The SketchUp API is a thin layer on top of our C/C++ source, so in many cases depending on use-case it won’t be noticeable for the end user because Ruby would be fast enough. The development time and maintenance is significantly higher in C than Ruby.

2 Likes

The following topic is about creating a scene graph using SketchUp Ruby …

Thanks , I have already done an serializer in ruby, but it’s quite slow.
Thanks for your answer

Before diving into C/C++ coding, use a profiler and get hard data on your specific scenario. The profiler has always yielded surprising results for me. Revealing areas I didn’t expect to be expensive and places where performance gains can be made from caching computations. (I’ve made a lot of speed optimisations in my pure Ruby extensions by effective caching, but you need to measure.)

SketchUp/speedup: Profiling tool for SketchUp Ruby extensions. (github.com)

2 Likes

Ok I will try to use profiling