Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在为 Ruby 编写一个 C 扩展,它需要大量使用时间对象。性能对于此应用程序至关重要。我应该如何从 C API 创建 Time 对象以获得最佳性能?我在 ruby.h 包含文件中没有找到任何相关的内容。
我一直只是使用rb_time_new- 它需要一个time_t和第二个参数以及时间的小数部分,以微秒为单位。
rb_time_new
time_t
time_t根据您所做的事情,仅存储(并对其进行计算)并仅在必须时才懒惰地转换为 ruby Time 对象可能是有意义的