image.domain\self_evolve\perf_types.mbt

75% · 3 / 4 points · 75 lines

Background color reports the state of each line. Underlined characters mark exact instrumented byte offsets; hover them to inspect the visit count.

  1. 1///|
  2. 2/// # 性能类型 self_evolve/perf_types
  3. 3///
  4. 4/// 图像处理库子模块
  5. 5/// 图像处理库子模块 Image processing library submodule
  6. 6// 性能回归检测类型 — 静态成本模型
  7. 7// Performance regression types: static cost model
  8. 8
  9. 9///|
  10. 10/// 算子成本估算。
  11. 11/// 描述 Op cost estimate.
  12. 12#derive(Eq, @debug.Debug)
  13. 13pub(all) struct OpCost {
  14. 14 op_tag : String
  15. 15 time_complexity : String
  16. 16 estimated_cost : Int32
  17. 17}
  18. 18
  19. 19///|
  20. 20pub extend OpCost with @debug.Debug::{to_repr}
  21. 21
  22. 22///|
  23. 23pub extend OpCost with Eq::{not_equal, equal}
  24. 24
  25. 25///|
  26. 26/// 管道性能基线。
  27. 27/// 管线 Pipeline performance baseline.
  28. 28#derive(Eq, @debug.Debug)
  29. 29pub(all) struct PerfBaseline {
  30. 30 pipeline_desc : String
  31. 31 total_cost : Int32
  32. 32 op_count : Int32
  33. 33 op_costs : Array[OpCost]
  34. 34}
  35. 35
  36. 36///|
  37. 37pub extend PerfBaseline with @debug.Debug::{to_repr}
  38. 38
  39. 39///|
  40. 40pub extend PerfBaseline with Eq::{not_equal, equal}
  41. 41
  42. 42///|
  43. 43/// 性能回归检测结果。
  44. 44/// 性能 Performance regression result.
  45. 45#derive(Eq, @debug.Debug)
  46. 46pub(all) struct PerfRegression {
  47. 47 original_cost : Int32
  48. 48 optimized_cost : Int32
  49. 49 delta : Int32
  50. 50 is_regression : Bool
  51. 51}
  52. 52
  53. 53///|
  54. 54pub extend PerfRegression with @debug.Debug::{to_repr}
  55. 55
  56. 56///|
  57. 57pub extend PerfRegression with Eq::{not_equal, equal}
  58. 58
  59. 59///|
  60. 60/// 优化是否改善性能。
  61. 61/// 描述 Whether optimization improved performance.
  62. 62pub fn PerfRegression::is_improvement(self : PerfRegression) -> Bool {
  63. 63● self.delta < 0
  64. 64}
  65. 65
  66. 66///|
  67. 67/// 改善百分比(0-100)。
  68. 68/// 描述 Improvement percentage (0-100).
  69. 69pub fn PerfRegression::improvement_pct(self : PerfRegression) -> Int32 {
  70. 70● if self.original_cost == 0 {
  71. 71○ 0
  72. 72 } else {
  73. 73● self.delta * 100 / self.original_cost
  74. 74 }
  75. 75}