1

For my job, I'm working on a project that involves working with robot sensor data. We've been using protobuf to serialize and transfer data. I'm trying to set up a new protobuf type but this data involves a large array (e.g. a million elements) of doubles.

So I have a protobuf file set up something like this

syntax = "proto2";

message Sensor {
optional string name = 1;
repeated double temperature = 2 [packed = true];
optional int32 humidity = 3;
}

Where "temperature" is meant to hold a large array of temperatures. But when it comes to actually creating the Sensor object and storing the temperatures the only way I can find to do this is through add_temperature

e.g.

Sensor sensor
sensor.add_temperature(23.4)

And so I'll need to call add_temperature a million times. Calling a function a million times strikes me as very inefficient way to build up an array of a million elements. Ideally I'd like to reserve an appropriate amount of memory and call one function that copies the data.

I see on the Overview page for Protobufs it's written that they are "less than maximally efficient" for large arrays of floating point numbers. Does this mean it's infeasible to use protobufs to serialize large arrays of floating points? Or is there a way I can make this work?

3
  • Do you need random access to these temperatures? Commented Apr 29, 2022 at 20:10
  • No I don't . The information is just to create an image. Commented Apr 29, 2022 at 20:22
  • 2
    The only way to know for sure is to write a small program and test the performance to see if it is adequate for your project. Commented Apr 29, 2022 at 21:30

1 Answer 1

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.