Пример #1
0
        private static void Main(string[] args)
        {
            Console.Title = "TrashMem Benchmark";
            Process[] testProcesses = Process.GetProcessesByName("ShittyMcUlow");

            if (testProcesses.Length > 0)
            {
                TrashMem TrashMem = new TrashMem(testProcesses.ToList().First());

                Console.WriteLine($"TrashMem Benchmark doing {TOTAL_RUNS} runs for every function");
                Console.WriteLine($">> 1 Byte Char");
                PrettyPrintValue("Read<char>", BenchmarkFunction(() => TrashMem.ReadUnmanaged <char>(STATIC_ADDRESS_INT16)));
                PrettyPrintValue("ReadChar", BenchmarkFunction(() => TrashMem.ReadChar(STATIC_ADDRESS_INT16)));
                PrettyPrintValue("ReadCharSafe", BenchmarkFunction(() => TrashMem.ReadCharSafe(STATIC_ADDRESS_INT16)));
                Console.WriteLine($">> 2 Byte Short");
                PrettyPrintValue("Read<short>", BenchmarkFunction(() => TrashMem.ReadUnmanaged <short>(STATIC_ADDRESS_INT16)));
                PrettyPrintValue("ReadInt16", BenchmarkFunction(() => TrashMem.ReadInt16(STATIC_ADDRESS_INT16)));
                PrettyPrintValue("ReadInt16Safe", BenchmarkFunction(() => TrashMem.ReadInt16Safe(STATIC_ADDRESS_INT16)));
                Console.WriteLine($">> 4 Byte Integer");
                PrettyPrintValue("Read<int>", BenchmarkFunction(() => TrashMem.ReadUnmanaged <int>(STATIC_ADDRESS_INT32)));
                PrettyPrintValue("ReadInt32", BenchmarkFunction(() => TrashMem.ReadInt32(STATIC_ADDRESS_INT32)));
                PrettyPrintValue("ReadInt32Safe", BenchmarkFunction(() => TrashMem.ReadInt32Safe(STATIC_ADDRESS_INT32)));
                Console.WriteLine($">> 8 Byte Long");
                PrettyPrintValue("Read<long>", BenchmarkFunction(() => TrashMem.ReadUnmanaged <long>(STATIC_ADDRESS_INT64)));
                PrettyPrintValue("ReadInt64", BenchmarkFunction(() => TrashMem.ReadInt64(STATIC_ADDRESS_INT64)));
                PrettyPrintValue("ReadInt64Safe", BenchmarkFunction(() => TrashMem.ReadInt64Safe(STATIC_ADDRESS_INT64)));
                Console.WriteLine($">> 12 Byte String");
                PrettyPrintValue("ReadString", BenchmarkFunction(() => TrashMem.ReadString(STATIC_ADDRESS_STRING, Encoding.ASCII, 12)));
                Console.WriteLine($">> 16 Byte Struct");
                PrettyPrintValue("ReadStruct<TestStruct>", BenchmarkFunction(() => TrashMem.ReadStruct <TestStruct>(STATIC_ADDRESS_INT16)));
            }
            else
            {
                Console.WriteLine("Error: please make sure a ShittyMcUlow process is running...");
            }

            Console.ReadLine();
        }
Пример #2
0
 public void ReadCharSafeTest()
 => Assert.AreEqual(0xF, TrashMem.ReadCharSafe(STATIC_ADDRESS_CHAR));