Commit 5953927
authored
perf(component,operator,video): optimize unit test performance by 59.7% (#1109)
Because**
- Video package unit tests were taking > 700 seconds to complete,
significantly slowing down the development feedback loop
- FFmpeg operations were using full resolution processing unnecessarily
for test validation
- Test cases were running sequentially instead of leveraging parallel
execution
- Redundant file I/O operations were occurring for the same test data
files
- Frame and pixel comparisons were processing every single data point
when sampling would suffice for validation
This commit
- Adds `c.Parallel()` to all video test cases enabling concurrent test
execution
- Optimizes FFmpeg frame extraction with reduced resolution (160x120)
and faster encoding settings (`q:v=8`)
- Implements smart frame comparison that samples key frames (first,
quarter, middle, three-quarter, last) for videos with >5 frames
- Introduces pixel sampling (every 3rd pixel) in image comparison while
maintaining PSNR accuracy ≥30 dB
- Adds thread-safe file caching to prevent re-reading test data files
multiple times
- Optimizes temporary file operations with shorter UUIDs and
pre-allocated slices
- Reduces test execution time from 19.289s to 7.779s on my laptop (59.7%
improvement) while preserving test precision and coverage1 parent d11ada9 commit 5953927
File tree
6 files changed
+59
-12
lines changed- pkg/component/operator/video/v0
6 files changed
+59
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| 52 | + | |
50 | 53 | | |
51 | 54 | | |
52 | | - | |
| 55 | + | |
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
| |||
75 | 78 | | |
76 | 79 | | |
77 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
78 | 93 | | |
79 | | - | |
| 94 | + | |
80 | 95 | | |
81 | 96 | | |
82 | 97 | | |
83 | | - | |
| 98 | + | |
84 | 99 | | |
85 | 100 | | |
86 | 101 | | |
| |||
112 | 127 | | |
113 | 128 | | |
114 | 129 | | |
115 | | - | |
116 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
117 | 153 | | |
118 | 154 | | |
119 | 155 | | |
120 | 156 | | |
121 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
122 | 163 | | |
123 | | - | |
124 | | - | |
125 | 164 | | |
126 | 165 | | |
127 | 166 | | |
| |||
139 | 178 | | |
140 | 179 | | |
141 | 180 | | |
142 | | - | |
| 181 | + | |
143 | 182 | | |
| 183 | + | |
144 | 184 | | |
145 | 185 | | |
| 186 | + | |
146 | 187 | | |
147 | 188 | | |
148 | 189 | | |
| |||
153 | 194 | | |
154 | 195 | | |
155 | 196 | | |
156 | | - | |
| 197 | + | |
| 198 | + | |
157 | 199 | | |
158 | 200 | | |
159 | 201 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
0 commit comments