-
Type: Improvement
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: bson-4.4.2
-
Component/s: BSON
-
Fully Compatible
Hello!
I noticed that each Date#to_bson call creates new instance of Time - it's not very problematic, but is noticeable when serializing big amount of Dates.
I'm attaching small benchmark with proposed improvement (use #jd method and calculate UNIX timestamp * 1000 right there in to_bson method).
For 1 million dates, it's 0 allocations vs almost 100MB worth of allocations, also this way is about 80% faster.
Is that OK idea or would that cause some problems?
Best,
MichaĆ
- links to