feat: added benchmarks

This commit is contained in:
2026-03-23 12:52:30 +03:00
parent f490b7383b
commit fe70aa5404
55 changed files with 6558 additions and 1 deletions
@@ -0,0 +1,141 @@
using System;
using System.Diagnostics;
using Google.Protobuf;
using UnityEngine;
public class BenchmarkRunner : MonoBehaviour
{
private const int N = 10_000;
private const int Warmup = 1_000;
private unsafe void Start()
{
var apMsg = new Arpack.Messages.MoveMessage
{
Position = new Arpack.Messages.Vector3 { X = 100, Y = -50, Z = 0 },
Velocity = new float[] { 1.5f, -2.5f, 0f },
Waypoints = new Arpack.Messages.Vector3[]
{
new Arpack.Messages.Vector3 { X = 10, Y = 20, Z = 0 },
new Arpack.Messages.Vector3 { X = -10, Y = 0, Z = 100 },
},
PlayerID = 999,
Active = true,
Visible = false,
Ghost = true,
Name = "PlayerOne",
};
var pbMsg = new Benchproto.MoveMessage
{
Position = new Benchproto.Vector3 { X = 100, Y = -50, Z = 0 },
PlayerId = 999,
Active = true,
Visible = false,
Ghost = true,
Name = "PlayerOne",
};
pbMsg.Velocity.AddRange(new float[] { 1.5f, -2.5f, 0f });
pbMsg.Waypoints.Add(new Benchproto.Vector3 { X = 10, Y = 20, Z = 0 });
pbMsg.Waypoints.Add(new Benchproto.Vector3 { X = -10, Y = 0, Z = 100 });
byte[] apBuf = new byte[256];
int apWireSize;
fixed (byte* ptr = apBuf) { apWireSize = apMsg.Serialize(ptr); }
byte[] apBytes = new byte[apWireSize];
Array.Copy(apBuf, apBytes, apWireSize);
byte[] pbBytes = pbMsg.ToByteArray();
int pbWireSize = pbBytes.Length;
byte[] protoOutputBuf = new byte[256];
// Warmup (JIT)
for (int i = 0; i < Warmup; i++)
{
fixed (byte* ptr = apBuf) { apMsg.Serialize(ptr); }
fixed (byte* ptr = apBytes) { Arpack.Messages.MoveMessage.Deserialize(ptr, out _); }
_ = pbMsg.ToByteArray();
_ = Benchproto.MoveMessage.Parser.ParseFrom(pbBytes);
var cos = new CodedOutputStream(protoOutputBuf);
pbMsg.WriteTo(cos);
cos.Flush();
}
Stopwatch sw;
long gcBefore, gcAfter;
// ArPack Serialize
GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect();
gcBefore = GC.GetTotalMemory(false);
sw = Stopwatch.StartNew();
for (int i = 0; i < N; i++)
{
fixed (byte* ptr = apBuf) { apMsg.Serialize(ptr); }
}
sw.Stop();
gcAfter = GC.GetTotalMemory(false);
Log("ArPack Serialize ", sw, N, gcAfter - gcBefore);
// ArPack Deserialize
GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect();
gcBefore = GC.GetTotalMemory(false);
sw = Stopwatch.StartNew();
for (int i = 0; i < N; i++)
{
fixed (byte* ptr = apBytes) { Arpack.Messages.MoveMessage.Deserialize(ptr, out _); }
}
sw.Stop();
gcAfter = GC.GetTotalMemory(false);
Log("ArPack Deserialize ", sw, N, gcAfter - gcBefore);
// Proto Serialize (alloc)
GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect();
gcBefore = GC.GetTotalMemory(false);
sw = Stopwatch.StartNew();
byte[] pbOut = null;
for (int i = 0; i < N; i++)
{
pbOut = pbMsg.ToByteArray();
}
sw.Stop();
gcAfter = GC.GetTotalMemory(false);
Log("Proto Serialize (alloc) ", sw, N, gcAfter - gcBefore);
_ = pbOut;
// Proto Deserialize (alloc)
GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect();
gcBefore = GC.GetTotalMemory(false);
sw = Stopwatch.StartNew();
for (int i = 0; i < N; i++)
{
_ = Benchproto.MoveMessage.Parser.ParseFrom(pbBytes);
}
sw.Stop();
gcAfter = GC.GetTotalMemory(false);
Log("Proto Deserialize (alloc)", sw, N, gcAfter - gcBefore);
// Proto Serialize (reuse buffer)
GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect();
gcBefore = GC.GetTotalMemory(false);
sw = Stopwatch.StartNew();
for (int i = 0; i < N; i++)
{
var cos = new CodedOutputStream(protoOutputBuf);
pbMsg.WriteTo(cos);
cos.Flush();
}
sw.Stop();
gcAfter = GC.GetTotalMemory(false);
Log("Proto Serialize (reuse) ", sw, N, gcAfter - gcBefore);
UnityEngine.Debug.Log($"[Bench] Wire sizes — ArPack: {apWireSize} bytes | Protobuf: {pbWireSize} bytes");
}
private static void Log(string label, Stopwatch sw, int n, long gcDelta)
{
double nsPerOp = sw.Elapsed.TotalMilliseconds * 1_000_000.0 / n;
long bPerOp = Math.Max(0, gcDelta) / n;
UnityEngine.Debug.Log($"[Bench] {label}: {nsPerOp,8:F1} ns/op | {bPerOp,6} B/op");
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: ac4456ca45dd64092a7c26b7fc6cff0f
@@ -0,0 +1,16 @@
{
"name": "Benchmarks",
"rootNamespace": "",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": true,
"overrideReferences": false,
"precompiledReferences": [
"Google.Protobuf"
],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 20a66c82a93d34a489c40c5f81b4a203
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,206 @@
// <auto-generated> arpack </auto-generated>
// Code generated by arpack. DO NOT EDIT.
#pragma warning disable CS8500
using System;
using System.Text;
namespace Arpack.Messages
{
public enum Opcode : ushort
{
Unknown = 0,
Authorize = 1,
JoinRoom = 2
}
public unsafe struct Vector3
{
public float X;
public float Y;
public float Z;
public int Serialize(byte* buffer)
{
byte* ptr = buffer;
*(ushort*)ptr = (ushort)((X - (-500f)) / (500f - (-500f)) * 65535f); ptr += 2;
*(ushort*)ptr = (ushort)((Y - (-500f)) / (500f - (-500f)) * 65535f); ptr += 2;
*(ushort*)ptr = (ushort)((Z - (-500f)) / (500f - (-500f)) * 65535f); ptr += 2;
return (int)(ptr - buffer);
}
public static int Deserialize(byte* buffer, out Vector3 msg)
{
byte* ptr = buffer;
msg = default;
msg.X = (float)(*(ushort*)ptr) / 65535f * (500f - (-500f)) + (-500f); ptr += 2;
msg.Y = (float)(*(ushort*)ptr) / 65535f * (500f - (-500f)) + (-500f); ptr += 2;
msg.Z = (float)(*(ushort*)ptr) / 65535f * (500f - (-500f)) + (-500f); ptr += 2;
return (int)(ptr - buffer);
}
}
public unsafe struct MoveMessage
{
public Vector3 Position;
public float[] Velocity;
public Vector3[] Waypoints;
public uint PlayerID;
public bool Active;
public bool Visible;
public bool Ghost;
public string Name;
public int Serialize(byte* buffer)
{
byte* ptr = buffer;
ptr += Position.Serialize(ptr);
for (int _iVelocity = 0; _iVelocity < 3; _iVelocity++)
{
*(float*)ptr = Velocity[_iVelocity]; ptr += 4;
}
*(ushort*)ptr = (ushort)(Waypoints?.Length ?? 0); ptr += 2;
if (Waypoints != null)
{
for (int _iWaypoints = 0; _iWaypoints < Waypoints.Length; _iWaypoints++)
{
ptr += Waypoints[_iWaypoints].Serialize(ptr);
}
}
*(uint*)ptr = PlayerID; ptr += 4;
byte _boolByte4 = 0;
if (Active) _boolByte4 |= (byte)(1 << 0);
if (Visible) _boolByte4 |= (byte)(1 << 1);
if (Ghost) _boolByte4 |= (byte)(1 << 2);
*ptr = _boolByte4; ptr++;
int _slenName = Name != null ? Encoding.UTF8.GetByteCount(Name) : 0;
*(ushort*)ptr = (ushort)_slenName; ptr += 2;
if (Name != null && _slenName > 0)
{
fixed (char* _charsName = Name)
{
Encoding.UTF8.GetBytes(_charsName, Name.Length, ptr, _slenName);
}
}
ptr += _slenName;
return (int)(ptr - buffer);
}
public static int Deserialize(byte* buffer, out MoveMessage msg)
{
byte* ptr = buffer;
msg = default;
ptr += Vector3.Deserialize(ptr, out msg.Position);
msg.Velocity = new float[3];
for (int _iVelocity = 0; _iVelocity < 3; _iVelocity++)
{
msg.Velocity[_iVelocity] = *(float*)ptr; ptr += 4;
}
int _lenWaypoints = *(ushort*)ptr; ptr += 2;
msg.Waypoints = new Vector3[_lenWaypoints];
for (int _iWaypoints = 0; _iWaypoints < _lenWaypoints; _iWaypoints++)
{
ptr += Vector3.Deserialize(ptr, out msg.Waypoints[_iWaypoints]);
}
msg.PlayerID = *(uint*)ptr; ptr += 4;
byte _boolByte4 = *ptr; ptr++;
msg.Active = (_boolByte4 & (1 << 0)) != 0;
msg.Visible = (_boolByte4 & (1 << 1)) != 0;
msg.Ghost = (_boolByte4 & (1 << 2)) != 0;
int _slenmsg_Name = *(ushort*)ptr; ptr += 2;
msg.Name = _slenmsg_Name > 0 ? Encoding.UTF8.GetString(ptr, _slenmsg_Name) : string.Empty;
ptr += _slenmsg_Name;
return (int)(ptr - buffer);
}
}
public unsafe struct SpawnMessage
{
public ulong EntityID;
public Vector3 Position;
public short Health;
public string[] Tags;
public byte[] Data;
public int Serialize(byte* buffer)
{
byte* ptr = buffer;
*(ulong*)ptr = EntityID; ptr += 8;
ptr += Position.Serialize(ptr);
*(short*)ptr = Health; ptr += 2;
*(ushort*)ptr = (ushort)(Tags?.Length ?? 0); ptr += 2;
if (Tags != null)
{
for (int _iTags = 0; _iTags < Tags.Length; _iTags++)
{
int _slenTags__iTags_ = Tags[_iTags] != null ? Encoding.UTF8.GetByteCount(Tags[_iTags]) : 0;
*(ushort*)ptr = (ushort)_slenTags__iTags_; ptr += 2;
if (Tags[_iTags] != null && _slenTags__iTags_ > 0)
{
fixed (char* _charsTags__iTags_ = Tags[_iTags])
{
Encoding.UTF8.GetBytes(_charsTags__iTags_, Tags[_iTags].Length, ptr, _slenTags__iTags_);
}
}
ptr += _slenTags__iTags_;
}
}
*(ushort*)ptr = (ushort)(Data?.Length ?? 0); ptr += 2;
if (Data != null)
{
for (int _iData = 0; _iData < Data.Length; _iData++)
{
*ptr = Data[_iData]; ptr += 1;
}
}
return (int)(ptr - buffer);
}
public static int Deserialize(byte* buffer, out SpawnMessage msg)
{
byte* ptr = buffer;
msg = default;
msg.EntityID = *(ulong*)ptr; ptr += 8;
ptr += Vector3.Deserialize(ptr, out msg.Position);
msg.Health = *(short*)ptr; ptr += 2;
int _lenTags = *(ushort*)ptr; ptr += 2;
msg.Tags = new string[_lenTags];
for (int _iTags = 0; _iTags < _lenTags; _iTags++)
{
int _slenmsg_Tags__iTags_ = *(ushort*)ptr; ptr += 2;
msg.Tags[_iTags] = _slenmsg_Tags__iTags_ > 0 ? Encoding.UTF8.GetString(ptr, _slenmsg_Tags__iTags_) : string.Empty;
ptr += _slenmsg_Tags__iTags_;
}
int _lenData = *(ushort*)ptr; ptr += 2;
msg.Data = new byte[_lenData];
for (int _iData = 0; _iData < _lenData; _iData++)
{
msg.Data[_iData] = *ptr; ptr += 1;
}
return (int)(ptr - buffer);
}
}
public unsafe struct EnvelopeMessage
{
public Opcode Code;
public byte Counter;
public int Serialize(byte* buffer)
{
byte* ptr = buffer;
*(ushort*)ptr = (ushort)Code; ptr += 2;
*ptr = Counter; ptr += 1;
return (int)(ptr - buffer);
}
public static int Deserialize(byte* buffer, out EnvelopeMessage msg)
{
byte* ptr = buffer;
msg = default;
msg.Code = (Opcode)(*(ushort*)ptr); ptr += 2;
msg.Counter = *ptr; ptr += 1;
return (int)(ptr - buffer);
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9755692abdaf54daf912862821fb9fd6
+768
View File
@@ -0,0 +1,768 @@
// <auto-generated>
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: move.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
using pbc = global::Google.Protobuf.Collections;
using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
namespace Benchproto {
/// <summary>Holder for reflection information generated from move.proto</summary>
public static partial class MoveReflection {
#region Descriptor
/// <summary>File descriptor for move.proto</summary>
public static pbr::FileDescriptor Descriptor {
get { return descriptor; }
}
private static pbr::FileDescriptor descriptor;
static MoveReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"Cgptb3ZlLnByb3RvEgpiZW5jaHByb3RvIioKB1ZlY3RvcjMSCQoBeBgBIAEo",
"AhIJCgF5GAIgASgCEgkKAXoYAyABKAIivwEKC01vdmVNZXNzYWdlEiUKCHBv",
"c2l0aW9uGAEgASgLMhMuYmVuY2hwcm90by5WZWN0b3IzEhAKCHZlbG9jaXR5",
"GAIgAygCEiYKCXdheXBvaW50cxgDIAMoCzITLmJlbmNocHJvdG8uVmVjdG9y",
"MxIRCglwbGF5ZXJfaWQYBCABKA0SDgoGYWN0aXZlGAUgASgIEg8KB3Zpc2li",
"bGUYBiABKAgSDQoFZ2hvc3QYByABKAgSDAoEbmFtZRgIIAEoCUItWitnaXRo",
"dWIuY29tL2VkbWFuZDQ2L2FycGFjay9iZW5jaG1hcmtzL3Byb3RvYgZwcm90",
"bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
new pbr::GeneratedClrTypeInfo(typeof(global::Benchproto.Vector3), global::Benchproto.Vector3.Parser, new[]{ "X", "Y", "Z" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Benchproto.MoveMessage), global::Benchproto.MoveMessage.Parser, new[]{ "Position", "Velocity", "Waypoints", "PlayerId", "Active", "Visible", "Ghost", "Name" }, null, null, null, null)
}));
}
#endregion
}
#region Messages
[global::System.Diagnostics.DebuggerDisplayAttribute("{ToString(),nq}")]
public sealed partial class Vector3 : pb::IMessage<Vector3>
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
, pb::IBufferMessage
#endif
{
private static readonly pb::MessageParser<Vector3> _parser = new pb::MessageParser<Vector3>(() => new Vector3());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pb::MessageParser<Vector3> Parser { get { return _parser; } }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pbr::MessageDescriptor Descriptor {
get { return global::Benchproto.MoveReflection.Descriptor.MessageTypes[0]; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public Vector3() {
OnConstruction();
}
partial void OnConstruction();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public Vector3(Vector3 other) : this() {
x_ = other.x_;
y_ = other.y_;
z_ = other.z_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public Vector3 Clone() {
return new Vector3(this);
}
/// <summary>Field number for the "x" field.</summary>
public const int XFieldNumber = 1;
private float x_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public float X {
get { return x_; }
set {
x_ = value;
}
}
/// <summary>Field number for the "y" field.</summary>
public const int YFieldNumber = 2;
private float y_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public float Y {
get { return y_; }
set {
y_ = value;
}
}
/// <summary>Field number for the "z" field.</summary>
public const int ZFieldNumber = 3;
private float z_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public float Z {
get { return z_; }
set {
z_ = value;
}
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override bool Equals(object other) {
return Equals(other as Vector3);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public bool Equals(Vector3 other) {
if (ReferenceEquals(other, null)) {
return false;
}
if (ReferenceEquals(other, this)) {
return true;
}
if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(X, other.X)) return false;
if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(Y, other.Y)) return false;
if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(Z, other.Z)) return false;
return Equals(_unknownFields, other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override int GetHashCode() {
int hash = 1;
if (X != 0F) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(X);
if (Y != 0F) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(Y);
if (Z != 0F) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(Z);
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash;
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void WriteTo(pb::CodedOutputStream output) {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
output.WriteRawMessage(this);
#else
if (X != 0F) {
output.WriteRawTag(13);
output.WriteFloat(X);
}
if (Y != 0F) {
output.WriteRawTag(21);
output.WriteFloat(Y);
}
if (Z != 0F) {
output.WriteRawTag(29);
output.WriteFloat(Z);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
#endif
}
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
if (X != 0F) {
output.WriteRawTag(13);
output.WriteFloat(X);
}
if (Y != 0F) {
output.WriteRawTag(21);
output.WriteFloat(Y);
}
if (Z != 0F) {
output.WriteRawTag(29);
output.WriteFloat(Z);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(ref output);
}
}
#endif
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public int CalculateSize() {
int size = 0;
if (X != 0F) {
size += 1 + 4;
}
if (Y != 0F) {
size += 1 + 4;
}
if (Z != 0F) {
size += 1 + 4;
}
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size;
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void MergeFrom(Vector3 other) {
if (other == null) {
return;
}
if (other.X != 0F) {
X = other.X;
}
if (other.Y != 0F) {
Y = other.Y;
}
if (other.Z != 0F) {
Z = other.Z;
}
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void MergeFrom(pb::CodedInputStream input) {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
input.ReadRawMessage(this);
#else
uint tag;
while ((tag = input.ReadTag()) != 0) {
if ((tag & 7) == 4) {
// Abort on any end group tag.
return;
}
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 13: {
X = input.ReadFloat();
break;
}
case 21: {
Y = input.ReadFloat();
break;
}
case 29: {
Z = input.ReadFloat();
break;
}
}
}
#endif
}
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
uint tag;
while ((tag = input.ReadTag()) != 0) {
if ((tag & 7) == 4) {
// Abort on any end group tag.
return;
}
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
break;
case 13: {
X = input.ReadFloat();
break;
}
case 21: {
Y = input.ReadFloat();
break;
}
case 29: {
Z = input.ReadFloat();
break;
}
}
}
}
#endif
}
[global::System.Diagnostics.DebuggerDisplayAttribute("{ToString(),nq}")]
public sealed partial class MoveMessage : pb::IMessage<MoveMessage>
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
, pb::IBufferMessage
#endif
{
private static readonly pb::MessageParser<MoveMessage> _parser = new pb::MessageParser<MoveMessage>(() => new MoveMessage());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pb::MessageParser<MoveMessage> Parser { get { return _parser; } }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pbr::MessageDescriptor Descriptor {
get { return global::Benchproto.MoveReflection.Descriptor.MessageTypes[1]; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public MoveMessage() {
OnConstruction();
}
partial void OnConstruction();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public MoveMessage(MoveMessage other) : this() {
position_ = other.position_ != null ? other.position_.Clone() : null;
velocity_ = other.velocity_.Clone();
waypoints_ = other.waypoints_.Clone();
playerId_ = other.playerId_;
active_ = other.active_;
visible_ = other.visible_;
ghost_ = other.ghost_;
name_ = other.name_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public MoveMessage Clone() {
return new MoveMessage(this);
}
/// <summary>Field number for the "position" field.</summary>
public const int PositionFieldNumber = 1;
private global::Benchproto.Vector3 position_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public global::Benchproto.Vector3 Position {
get { return position_; }
set {
position_ = value;
}
}
/// <summary>Field number for the "velocity" field.</summary>
public const int VelocityFieldNumber = 2;
private static readonly pb::FieldCodec<float> _repeated_velocity_codec
= pb::FieldCodec.ForFloat(18);
private readonly pbc::RepeatedField<float> velocity_ = new pbc::RepeatedField<float>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public pbc::RepeatedField<float> Velocity {
get { return velocity_; }
}
/// <summary>Field number for the "waypoints" field.</summary>
public const int WaypointsFieldNumber = 3;
private static readonly pb::FieldCodec<global::Benchproto.Vector3> _repeated_waypoints_codec
= pb::FieldCodec.ForMessage(26, global::Benchproto.Vector3.Parser);
private readonly pbc::RepeatedField<global::Benchproto.Vector3> waypoints_ = new pbc::RepeatedField<global::Benchproto.Vector3>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public pbc::RepeatedField<global::Benchproto.Vector3> Waypoints {
get { return waypoints_; }
}
/// <summary>Field number for the "player_id" field.</summary>
public const int PlayerIdFieldNumber = 4;
private uint playerId_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public uint PlayerId {
get { return playerId_; }
set {
playerId_ = value;
}
}
/// <summary>Field number for the "active" field.</summary>
public const int ActiveFieldNumber = 5;
private bool active_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public bool Active {
get { return active_; }
set {
active_ = value;
}
}
/// <summary>Field number for the "visible" field.</summary>
public const int VisibleFieldNumber = 6;
private bool visible_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public bool Visible {
get { return visible_; }
set {
visible_ = value;
}
}
/// <summary>Field number for the "ghost" field.</summary>
public const int GhostFieldNumber = 7;
private bool ghost_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public bool Ghost {
get { return ghost_; }
set {
ghost_ = value;
}
}
/// <summary>Field number for the "name" field.</summary>
public const int NameFieldNumber = 8;
private string name_ = "";
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public string Name {
get { return name_; }
set {
name_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override bool Equals(object other) {
return Equals(other as MoveMessage);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public bool Equals(MoveMessage other) {
if (ReferenceEquals(other, null)) {
return false;
}
if (ReferenceEquals(other, this)) {
return true;
}
if (!object.Equals(Position, other.Position)) return false;
if(!velocity_.Equals(other.velocity_)) return false;
if(!waypoints_.Equals(other.waypoints_)) return false;
if (PlayerId != other.PlayerId) return false;
if (Active != other.Active) return false;
if (Visible != other.Visible) return false;
if (Ghost != other.Ghost) return false;
if (Name != other.Name) return false;
return Equals(_unknownFields, other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override int GetHashCode() {
int hash = 1;
if (position_ != null) hash ^= Position.GetHashCode();
hash ^= velocity_.GetHashCode();
hash ^= waypoints_.GetHashCode();
if (PlayerId != 0) hash ^= PlayerId.GetHashCode();
if (Active != false) hash ^= Active.GetHashCode();
if (Visible != false) hash ^= Visible.GetHashCode();
if (Ghost != false) hash ^= Ghost.GetHashCode();
if (Name.Length != 0) hash ^= Name.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash;
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void WriteTo(pb::CodedOutputStream output) {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
output.WriteRawMessage(this);
#else
if (position_ != null) {
output.WriteRawTag(10);
output.WriteMessage(Position);
}
velocity_.WriteTo(output, _repeated_velocity_codec);
waypoints_.WriteTo(output, _repeated_waypoints_codec);
if (PlayerId != 0) {
output.WriteRawTag(32);
output.WriteUInt32(PlayerId);
}
if (Active != false) {
output.WriteRawTag(40);
output.WriteBool(Active);
}
if (Visible != false) {
output.WriteRawTag(48);
output.WriteBool(Visible);
}
if (Ghost != false) {
output.WriteRawTag(56);
output.WriteBool(Ghost);
}
if (Name.Length != 0) {
output.WriteRawTag(66);
output.WriteString(Name);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
#endif
}
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
if (position_ != null) {
output.WriteRawTag(10);
output.WriteMessage(Position);
}
velocity_.WriteTo(ref output, _repeated_velocity_codec);
waypoints_.WriteTo(ref output, _repeated_waypoints_codec);
if (PlayerId != 0) {
output.WriteRawTag(32);
output.WriteUInt32(PlayerId);
}
if (Active != false) {
output.WriteRawTag(40);
output.WriteBool(Active);
}
if (Visible != false) {
output.WriteRawTag(48);
output.WriteBool(Visible);
}
if (Ghost != false) {
output.WriteRawTag(56);
output.WriteBool(Ghost);
}
if (Name.Length != 0) {
output.WriteRawTag(66);
output.WriteString(Name);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(ref output);
}
}
#endif
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public int CalculateSize() {
int size = 0;
if (position_ != null) {
size += 1 + pb::CodedOutputStream.ComputeMessageSize(Position);
}
size += velocity_.CalculateSize(_repeated_velocity_codec);
size += waypoints_.CalculateSize(_repeated_waypoints_codec);
if (PlayerId != 0) {
size += 1 + pb::CodedOutputStream.ComputeUInt32Size(PlayerId);
}
if (Active != false) {
size += 1 + 1;
}
if (Visible != false) {
size += 1 + 1;
}
if (Ghost != false) {
size += 1 + 1;
}
if (Name.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
}
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size;
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void MergeFrom(MoveMessage other) {
if (other == null) {
return;
}
if (other.position_ != null) {
if (position_ == null) {
Position = new global::Benchproto.Vector3();
}
Position.MergeFrom(other.Position);
}
velocity_.Add(other.velocity_);
waypoints_.Add(other.waypoints_);
if (other.PlayerId != 0) {
PlayerId = other.PlayerId;
}
if (other.Active != false) {
Active = other.Active;
}
if (other.Visible != false) {
Visible = other.Visible;
}
if (other.Ghost != false) {
Ghost = other.Ghost;
}
if (other.Name.Length != 0) {
Name = other.Name;
}
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void MergeFrom(pb::CodedInputStream input) {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
input.ReadRawMessage(this);
#else
uint tag;
while ((tag = input.ReadTag()) != 0) {
if ((tag & 7) == 4) {
// Abort on any end group tag.
return;
}
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
if (position_ == null) {
Position = new global::Benchproto.Vector3();
}
input.ReadMessage(Position);
break;
}
case 18:
case 21: {
velocity_.AddEntriesFrom(input, _repeated_velocity_codec);
break;
}
case 26: {
waypoints_.AddEntriesFrom(input, _repeated_waypoints_codec);
break;
}
case 32: {
PlayerId = input.ReadUInt32();
break;
}
case 40: {
Active = input.ReadBool();
break;
}
case 48: {
Visible = input.ReadBool();
break;
}
case 56: {
Ghost = input.ReadBool();
break;
}
case 66: {
Name = input.ReadString();
break;
}
}
}
#endif
}
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
uint tag;
while ((tag = input.ReadTag()) != 0) {
if ((tag & 7) == 4) {
// Abort on any end group tag.
return;
}
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
break;
case 10: {
if (position_ == null) {
Position = new global::Benchproto.Vector3();
}
input.ReadMessage(Position);
break;
}
case 18:
case 21: {
velocity_.AddEntriesFrom(ref input, _repeated_velocity_codec);
break;
}
case 26: {
waypoints_.AddEntriesFrom(ref input, _repeated_waypoints_codec);
break;
}
case 32: {
PlayerId = input.ReadUInt32();
break;
}
case 40: {
Active = input.ReadBool();
break;
}
case 48: {
Visible = input.ReadBool();
break;
}
case 56: {
Ghost = input.ReadBool();
break;
}
case 66: {
Name = input.ReadString();
break;
}
}
}
}
#endif
}
#endregion
}
#endregion Designer generated code
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c7457f233226e42568ebd6ff92de57fc