public void ByteArrayToStructureT() { var array = new byte[100]; for (var l = 0; l < array.Length; l++) { array[l] = (byte)l; } int a = 0; for (a = 0; a < 1000000; a++) { var ans1 = MavlinkUtil.ByteArrayToStructureT <MAVLink.mavlink_heartbeat_t>(array, 6); } }
private void but_structtest_Click(object sender, EventArgs e) { var array = new byte[100]; for (var l = 0; l < array.Length; l++) { array[l] = (byte)l; } var a = 0; var start = DateTime.MinValue; var end = DateTime.MinValue; start = DateTime.Now; for (a = 0; a < 1000000; a++) { var obj = (object)new MAVLink.mavlink_heartbeat_t(); MavlinkUtil.ByteArrayToStructure(array, ref obj, 6); } end = DateTime.Now; Console.WriteLine("ByteArrayToStructure " + (end - start).TotalMilliseconds); start = DateTime.Now; for (a = 0; a < 1000000; a++) { var ans1 = MavlinkUtil.ByteArrayToStructureT <MAVLink.mavlink_heartbeat_t>(array, 6); } end = DateTime.Now; Console.WriteLine("ByteArrayToStructureT<> " + (end - start).TotalMilliseconds); start = DateTime.Now; for (a = 0; a < 1000000; a++) { var ans2 = MavlinkUtil.ReadUsingPointer <MAVLink.mavlink_heartbeat_t>(array, 6); } end = DateTime.Now; Console.WriteLine("ReadUsingPointer " + (end - start).TotalMilliseconds); start = DateTime.Now; for (a = 0; a < 1000000; a++) { var ans3 = MavlinkUtil.ByteArrayToStructureGC <MAVLink.mavlink_heartbeat_t>(array, 6); } end = DateTime.Now; Console.WriteLine("ByteArrayToStructureGC " + (end - start).TotalMilliseconds); }