I am writing a C extension for Ruby, which needs to heavily use time objects. The performance is critical for this application. How should I go about creating Time objects from C API for maximum performance? I did not find anything relevant in ruby.h include file.
I've always just used rb_time_new - it takes a time_t and a second parameter with the fractional part of the time, in microseconds.
Depending on what you are doing it might make sense to only store the time_t (and do your calculations on those) and lazily convert to ruby Time objects only when you have to
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With