Class to mimick Java's ByteBuffer which is used heavily in Flatbuffers
Example #1
0
        static void LocalPerformanceTest()
        {
            byte[] data = System.IO.File.ReadAllBytes ("/Users/mzaks/Downloads/flatbuffers-master/samples/doge/gen/player_state.mon");
            int length1 = data.Length, length2 = 0;
            var byteBuffer = new FlatBuffers.ByteBuffer (data);
            var gamestate = GameStateRoot.GetRootAsGameStateRoot (byteBuffer);
            Stopwatch watch = new Stopwatch ();
            int numberOfRuns = 100;
            double[] m = new double[numberOfRuns];
            for (int i = 0; i < numberOfRuns; i++) {
                watch.Start ();
                FBDeserializationService.singleton.Deserialize (gamestate);
                createSomeGroups ();

                FBSerialisationService.singleton.corePool = FBDeserializationService.singleton.corePool;
                FBSerialisationService.singleton.metaPool = FBDeserializationService.singleton.metaPool;

                data = FBSerialisationService.singleton.GenerateGameState ();
                length2 = data.Length;
                byteBuffer = new FlatBuffers.ByteBuffer (data);
                gamestate = GameStateRoot.GetRootAsGameStateRoot (byteBuffer);
                watch.Stop ();
                m [i] = watch.Elapsed.TotalMilliseconds;
            }
            Console.WriteLine ("Hello World! " + gamestate.GameData1.PlayerName);
            for (int i = 0; i < numberOfRuns; i++) {
                Console.WriteLine ("Elapsed " + ((i == 0) ? m [i] : m [i] - m [i - 1]));
            }
            Console.WriteLine ("Elapsed AVG " + ((m [numberOfRuns - 1] - m [0]) / (numberOfRuns - 1)));
            Console.WriteLine ("Number of core pool entities " + FBDeserializationService.singleton.corePool.Count);
            Console.WriteLine ("Number of meta pool entities " + FBDeserializationService.singleton.metaPool.Count);
            Console.WriteLine ("Length before: " + length1 + " after: " + length2);
            System.IO.File.WriteAllBytes (@"/Users/mzaks/Downloads/flatbuffers-master/samples/doge/gen/player_state2.mon", data);
        }
Example #2
0
 static byte[] runTest(byte[] data)
 {
     var byteBuffer = new FlatBuffers.ByteBuffer (data);
     var gamestate = GameStateRoot.GetRootAsGameStateRoot (byteBuffer);
     FBDeserializationService.singleton.Deserialize (gamestate);
     createSomeGroups ();
     //
     FBSerialisationService.singleton.corePool = FBDeserializationService.singleton.corePool;
     FBSerialisationService.singleton.metaPool = FBDeserializationService.singleton.metaPool;
     //
     FBSerialisationService.singleton.GenerateGameState ();
     //
     return data;
 }
Example #3
0
 public GameData __init(int _i, ByteBuffer _bb)
 {
     bb_pos = _i; bb = _bb; return this;
 }
Example #4
0
 public static GameData GetRootAsGameData(ByteBuffer _bb)
 {
     return GetRootAsGameData(_bb, new GameData());
 }
Example #5
0
 public static uvSwapItemMesh GetRootAsuvSwapItemMesh(ByteBuffer _bb, uvSwapItemMesh obj)
 {
     return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb));
 }
Example #6
0
 public animation __init(int _i, ByteBuffer _bb)
 {
     bb_pos = _i; bb = _bb; return this;
 }
Example #7
0
 public static animation GetRootAsanimation(ByteBuffer _bb)
 {
     return GetRootAsanimation(_bb, new animation());
 }
 public static ListModulesResponse GetRootAsListModulesResponse(ByteBuffer _bb, ListModulesResponse obj)
 {
     return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb));
 }
Example #9
0
 public static TypeAmount GetRootAsTypeAmount(ByteBuffer _bb)
 {
     return GetRootAsTypeAmount(_bb, new TypeAmount());
 }
 public animationMeshTimeSample __init(int _i, ByteBuffer _bb)
 {
     bb_pos = _i; bb = _bb; return this;
 }
 public static animationMeshTimeSample GetRootAsanimationMeshTimeSample(ByteBuffer _bb, animationMeshTimeSample obj)
 {
     return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb));
 }
 public static animationMeshTimeSample GetRootAsanimationMeshTimeSample(ByteBuffer _bb)
 {
     return GetRootAsanimationMeshTimeSample(_bb, new animationMeshTimeSample());
 }
Example #13
0
 public static ActorData GetRootAsActorData(ByteBuffer _bb)
 {
     return GetRootAsActorData(_bb, new ActorData());
 }
Example #14
0
 public BreakpointEvent __init(int _i, ByteBuffer _bb)
 {
     bb_pos = _i; bb = _bb; return this;
 }
Example #15
0
 public static BreakpointEvent GetRootAsBreakpointEvent(ByteBuffer _bb, BreakpointEvent obj)
 {
     return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb));
 }
 public ListBreakpointsRequest __init(int _i, ByteBuffer _bb)
 {
     bb_pos = _i; bb = _bb; return this;
 }
 public static ListModulesResponse GetRootAsListModulesResponse(ByteBuffer _bb)
 {
     return GetRootAsListModulesResponse(_bb, new ListModulesResponse());
 }
Example #18
0
 public static TypeAmount GetRootAsTypeAmount(ByteBuffer _bb, TypeAmount obj)
 {
     return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb));
 }
 public ListModulesResponse __init(int _i, ByteBuffer _bb)
 {
     bb_pos = _i; bb = _bb; return this;
 }
Example #20
0
 public TypeAmount __init(int _i, ByteBuffer _bb)
 {
     bb_pos = _i; bb = _bb; return this;
 }
Example #21
0
 public static animation GetRootAsanimation(ByteBuffer _bb, animation obj)
 {
     return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb));
 }
 public static PulseKeyFrameData_Float GetRootAsPulseKeyFrameData_Float(ByteBuffer _bb)
 {
     return GetRootAsPulseKeyFrameData_Float(_bb, new PulseKeyFrameData_Float());
 }
Example #23
0
 public static uvSwapItemMesh GetRootAsuvSwapItemMesh(ByteBuffer _bb)
 {
     return GetRootAsuvSwapItemMesh(_bb, new uvSwapItemMesh());
 }
 public static PulseKeyFrameData_Float GetRootAsPulseKeyFrameData_Float(ByteBuffer _bb, PulseKeyFrameData_Float obj)
 {
     return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb));
 }
Example #25
0
 public uvSwapItemMesh __init(int _i, ByteBuffer _bb)
 {
     bb_pos = _i; bb = _bb; return this;
 }
 public PulseKeyFrameData_Float __init(int _i, ByteBuffer _bb)
 {
     bb_pos = _i; bb = _bb; return this;
 }
Example #27
0
 public static GameData GetRootAsGameData(ByteBuffer _bb, GameData obj)
 {
     return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb));
 }
 public static ListBreakpointsRequest GetRootAsListBreakpointsRequest(ByteBuffer _bb)
 {
     return GetRootAsListBreakpointsRequest(_bb, new ListBreakpointsRequest());
 }
Example #29
0
 public XObject __init(int _i, ByteBuffer _bb)
 {
     bb_pos = _i; bb = _bb; return this;
 }
 public static ListBreakpointsRequest GetRootAsListBreakpointsRequest(ByteBuffer _bb, ListBreakpointsRequest obj)
 {
     return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb));
 }