Any suggestions, please?

On Wednesday, December 20, 2017 at 10:00:31 PM UTC+9, Ravi wrote:
>
> I have defined the Protocol Buffers message file as follows:
>
> syntax = "proto3";
> package Tutorial;
> import "google/protobuf/timestamp.proto";
> option csharp_namespace = "Tutorial";
>
> message PointCloud {
>   int32 width  = 1;
>   int32 height = 2;
>
>   message Point {
>     float x     = 1;
>     float y     = 2;
>     float z     = 3;
>     fixed32 rgb = 4;
>   }
>   repeated Point points = 3;
>   google.protobuf.Timestamp timestamp = 4;
> }
>
> This is how I am preparing the data and serializing it in C#:
> using Google.Protobuf;
> using Tutorial;
> using ZeroMQ;
>
> PointCloud pointCloud = new PointCloud();
> pointCloud.Height = Height
> pointCloud.Width = Width;
> pointCloud.Timestamp = Timestamp.FromDateTime(DateTime.UtcNow);
>
> for (var index = 0; index < POINTS3D_COUNT; index++) {
>   PointCloud.Types.Point point = new PointCloud.Types.Point {
>     X = points3D[index].X,
>     Y = points3D[index].Y,
>     Z = points3D[index].Z,
>     Rgb = (uint)((red << 16) | (green << 8) | blue)
>   };
>
>   pointCloud.Points.Add(point);
> }
>
> zmqPublisher.Send(new ZFrame(pointCloud.ToByteArray()));
>
> This is how I deserialize the data in C++:
> while (receive) {
>   zmq::message_t msg;
>   int rc = zmq_socket.recv(&msg);
>   if (rc) {
>     Tutorial::PointCloud point_cloud;
>     point_cloud.ParseFromArray(msg.data(), msg.size());
>   }point_cloud.ParseFromArray(msg.data(), msg.size())
> }
>
> I am able to get the data back properly. However, the serialization and 
> deserialization process seems slow. 
>
>    - I used *System.Diagnostics.Stopwatch *in C# and noticed that 
>    *pointCloud.ToByteArray()* is taking 100ms approximately.
>    - Similarly I used *std::chrono::steady_clock::now()* in C++ and 
>    noticed that *point_cloud.ParseFromArray(msg.data(), msg.size())* is 
>    taking 96ms approximately.
>    - Just for information, the length of the byte array is roughly 
>    3,784,000.
>    
>
> *I want to know how to speed up serialization and deserialization process?*
>
> -
> Thanks
> Ravi
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to