No Description
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.

RunSettings.cs 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using System.Runtime.Serialization;
  3. using Unity.PerformanceTesting.Runtime;
  4. namespace Unity.PerformanceTesting.Data
  5. {
  6. /// <summary>
  7. /// Settings store
  8. /// @TODO make it public along with guidelines of how and when to use
  9. /// @TODO add a property bag
  10. /// </summary>
  11. [Serializable]
  12. internal class RunSettings : IDeserializationCallback
  13. {
  14. public RunSettings(params string[] args)
  15. {
  16. if (int.TryParse(Utils.GetArg(args, "-performance-measurement-count"), out var measurementMultiplier))
  17. {
  18. MeasurementCount = measurementMultiplier;
  19. }
  20. }
  21. private static RunSettings m_Instance;
  22. /// <summary>
  23. /// Singleton instance of settings.
  24. /// </summary>
  25. public static RunSettings Instance
  26. {
  27. get
  28. {
  29. if (m_Instance == null)
  30. {
  31. m_Instance = ResourcesLoader.Load<RunSettings>(Utils.RunSettings, Utils.PlayerPrefKeySettingsJSON);
  32. }
  33. return m_Instance;
  34. }
  35. set { m_Instance = value; }
  36. }
  37. /// <summary>
  38. /// Measurement counts will be overriden by specified value when using Measure.Method and Measure.Frames.
  39. /// </summary>
  40. public int MeasurementCount = -1;
  41. /// <summary>
  42. /// Validates the deserialized object.
  43. /// </summary>
  44. /// <param name="sender">The object that initiated the deserialization process.</param>
  45. public void OnDeserialization(object sender)
  46. {
  47. if (MeasurementCount < -1)
  48. {
  49. throw new SerializationException("MeasurementCount cannot be negative, except for the initial value of -1.");
  50. }
  51. }
  52. }
  53. }