Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Varint optimizations #269

Merged
merged 1 commit into from
Oct 1, 2015
Merged

Conversation

zanker
Copy link
Contributor

@zanker zanker commented Sep 28, 2015

Per #268, here's the results of benchmarking C vs pure Ruby. For the sake of being thorough, I also tested the variant used in the other protobuf gem (which was related to what @jjowdy) suggested, and it performed worst.

       user     system      total        real
pure_protobuf  1.080000   0.010000   1.090000 (  1.087074)
pure_alt  1.260000   0.010000   1.270000 (  1.275954)
c  0.700000   0.000000   0.700000 (  0.708581)

I also tested the C encoder in the varint gem, and it appears to be slower. This might be because with how protobuf is implemented, we need to create a StringIO class, rewind it, and then call read in order to get. Rewriting things might speed it up, but that's outside of what I'm looking to do in this PR.

Thanks @hollow and @codekitchen for the extension!

@zanker zanker force-pushed the zanker/varint branch 2 times, most recently from e09baab to b78367f Compare September 28, 2015 03:53
require 'spec_helper'

RSpec.describe Protobuf::Varint do
VALUES = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I picked pretty arbitrary values to test that these are working. If someone has another suggestion, happy to include something else.

abrandoned added a commit that referenced this pull request Oct 1, 2015
@abrandoned abrandoned merged commit 21d938e into ruby-protobuf:master Oct 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants