This changes to_time to use Ruby's built in Time.at with nanos support
rather than calculating a float and passing it to Time.at. The new
version runs about 3 times faster than the original version and
allocates fewer objects.
Warming up --------------------------------------
protobuf#to_time 57.296k i/100ms
faster#to_time 133.229k i/100ms
Calculating -------------------------------------
protobuf#to_time 635.361k (± 2.1%) i/s - 3.209M in 5.052169s
faster#to_time 1.873M (± 3.3%) i/s - 9.459M in 5.055169s
Comparison:
faster#to_time: 1873368.8 i/s
protobuf#to_time: 635361.4 i/s - 2.95x slower
Calculating -------------------------------------
protobuf#to_time 326.000 memsize ( 126.000 retained)
7.000 objects ( 2.000 retained)
0.000 strings ( 0.000 retained)
faster#to_time 86.000 memsize ( 0.000 retained)
1.000 objects ( 0.000 retained)
0.000 strings ( 0.000 retained)
Comparison:
faster#to_time: 86 allocated
protobuf#to_time: 326 allocated - 3.79x more
In general, I think it will help us to debug issues if we have less C
code and more Ruby code. This method can be implemented in pure Ruby,
so this commit converts it to pure Ruby.
* Revert "Revert "Enable the ignore_unknown_field option in the Ruby unmarshal options" (#5511)"
This reverts commit be1716a6d0.
* Separate ruby conformance test on Mac
* Fix shell syntax
* Fix test
This adds the ability for the MRI Ruby library to optionally pass in a
ignore_unknown_fields option when decoding JSON. The functionality was
added upstream in upb, this change exposes that option.
* This allows for ruby code to catch and handle Protobuf
TypeErrors separately from the standard Ruby TypeError
* Maintains backwards compatibility by having the new
Google::Protobuf::TypeError inherit from the base
TypeError. Any code that was catching TypeError should
continue to work.
This fixes the test_acts_likes_an_array test in RepeatedFieldTest, which
checks that repeated fields respond to the same methods as regular Ruby
arrays. The bsearch_index and dig array methods seem to be new in Ruby
2.3 and so we should support those.
This involved fixing a few important bugs in the
Ruby implementation -- mostly cases of mixing
upb field types and descriptor types (upb field
types do not distinguish between int/sint/fixed/sfixed
like descriptor types do).
Also added protobuf-specific exceptions so parse
errors can be caught specifically.
Change-Id: Ib49d3db976900b2c6f3455c8b88af52cfb86e036
* make consistent between mri and jruby
* create a #to_h and have it use symbols for keys
* add #to_json and #to_proto helpers on the Google::Protobuf message classes
starting to make `RepeatedField` quack like an array
additional changes:
* make sure gemspec gets all ruby code files
* add homepage in gem spec removes one of the warnings, and the gem spec authors are pushing
everyone to include a homepage in the gem
* remove excess whitespace in test suite to bring formatting inline with the rest of the file
system. The Ruby module build now uses an amalgamated distribution of
upb, and successfully builds a Ruby gem called 'google-protobuf' with
module 'google/protobuf'.