using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Configs; using BenchmarkDotNet.Environments; using BenchmarkDotNet.Jobs; using CodeWalker.Core.Utils; using CodeWalker.GameFiles; using System; using System.Buffers.Binary; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Web; using System.Xml; using System.Xml.Linq; namespace CodeWalker.Benchmarks { [MemoryDiagnoser] public class Benchmarks { public const string markup = @" vehshare brabusgt600brabusgt600 brabusgt600 GT 600 BRABUS null null null null null ta176m177 LAYOUT_LOW BULLET_COVER_OFFSET_INFO EXPLOSION_INFO_DEFAULT DEFAULT_FOLLOW_VEHICLE_CAMERA MID_BOX_VEHICLE_AIM_CAMERA VEHICLE_BONNET_CAMERA_NEAR_EXTRA_HIGH DEFAULT_POV_CAMERA VFXVEHICLEINFO_CAR_BULLET 60.000000 80.000000 100.000000 120.000000 500.000000 500.000000 SWANKNESS_3 FLAG_SPORTS FLAG_RICH_CAR FLAG_NO_BROKEN_DOWN_SCENARIO FLAG_RECESSED_TAILLIGHT_CORONAS FLAG_NO_HEAVY_BRAKE_ANIMATION VEHICLE_TYPE_CAR VPT_FRONT_AND_BACK_PLATES VDT_BANSHEE VC_SPORT VWT_HIEND docktrailer trailers trailers2 trailers3 trailers4 tanker trailerlogs tr2 trflat S_M_Y_Cop_01 WHEEL_FRONT_RIGHT_CAMERA WHEEL_FRONT_LEFT_CAMERA WHEEL_REAR_RIGHT_CAMERA WHEEL_REAR_LEFT_CAMERA LOW_BULLET_FRONT_LEFT LOW_BULLET_FRONT_RIGHT vehicles_banshee_interior brabusgt600 "; private byte[] data; private RpfFileEntry fileEntry; [GlobalSetup] public void Setup() { data = new byte[2048]; var random = new Random(42); for (int i = 0; i < data.Length; i++) { data[i] = (byte)random.Next(byte.MinValue, byte.MaxValue); } GTA5Keys.LoadFromPath("C:\\Program Files\\Rockstar Games\\Grand Theft Auto V", ""); } //[Benchmark(Baseline = true)] //public void RunLoad() //{ // var vehiclesFileExpected = new VehiclesFile(); // vehiclesFileExpected.LoadOld(data, fileEntry); //} //[Benchmark] //public void RunLoadNew() //{ // var vehiclesFile = new VehiclesFile(); // vehiclesFile.Load(data, fileEntry); //} [Benchmark] public void DecryptNGSpan() { GTACrypto.DecryptNG(data.AsSpan(), "kaas", 2048); } [Benchmark] public void DecryptNG() { GTACrypto.DecryptNG(data, "kaas", 2048); } } }