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

Optimize byte array encoding #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mvollrath
Copy link

Copy the entire byte array instead of iterating over one byte at a time. This makes CBOR much much faster at encoding messages with large binary blobs.

Benchmarking on this data, a ROS2 sensor_msgs/Image of 640x480 RGB:

var benchmarkData = {
  header: {
    stamp: {
      sec: 1,
      nanosec: 1e8
    },
    frame_id: ""
  },
  height: 480,
  width: 640,
  encoding: "RGB",
  is_bigendian: 0,
  step: 640,
  data: Uint8Array.from(Array.from({length: 640 * 480 * 3}, () => 128))
};

master

CBOR encode: 20.234ms

fast_byte_array_encoding

CBOR encode: 1.288ms

@coveralls
Copy link

Coverage Status

Coverage increased (+0.003%) to 99.265% when pulling 1a6de15 on mvollrath:fast_byte_array_encoding into 65dc496 on paroga:master.

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.

None yet

2 participants