Unofficial CardLife revival project, pronounced like "celery"
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.5KB

  1. using System.Diagnostics;
  2. using System.Linq;
  3. using System.Reflection;
  4. using HarmonyLib;
  5. #if DEBUG
  6. namespace CLre.Fixes
  7. {
  8. public class StartupSpeedup
  9. {
  10. }
  11. [HarmonyPatch(typeof(FrontEnd.FrontEndContextRoot), "WaitForFrameworkInitialization")]
  12. //[HarmonyPatch]
  13. class Speedup_Benchmark3
  14. {
  15. internal static Stopwatch test = null;
  16. public static void Prefix()
  17. {
  18. test = Stopwatch.StartNew();
  19. }
  20. }
  21. [HarmonyPatch(typeof(FrontEnd.MainFrontEnd), "RequestPlayerId")]
  22. //[HarmonyPatch]
  23. class Speedup_Benchmark
  24. {
  25. internal static Stopwatch test = null;
  26. public static void Prefix()
  27. {
  28. test.Stop();
  29. long elapsed = test.ElapsedMilliseconds;
  30. API.Utility.Logging.Log($"OnContextInitialized completed in ~{elapsed}ms");
  31. }
  32. }
  33. [HarmonyPatch(typeof(FrontEnd.MainFrontEnd), "RegisterCustomHtmlElementTypes")]
  34. class Speedup_Benchmark2
  35. {
  36. public static void Prefix()
  37. {
  38. if (Speedup_Benchmark3.test != null)
  39. {
  40. Speedup_Benchmark3.test.Stop();
  41. long elapsed = Speedup_Benchmark3.test.ElapsedMilliseconds;
  42. API.App.Client.LogInitComplete += (_, __) =>
  43. {
  44. API.Utility.Logging.Log($"Scene loaded in ~{elapsed}ms");
  45. };
  46. }
  47. Speedup_Benchmark.test = Stopwatch.StartNew();
  48. }
  49. }
  50. }
  51. #endif