API
 
Loading...
Searching...
No Matches
streamWriterSizing_test.cpp
Go to the documentation of this file.
1
2#include "../../../tests/catch2/catch.hpp"
3#include "../../tests/testMacrosINDI.hpp"
4
5#include "../streamWriter.hpp"
6
7using namespace MagAOX::app;
8
9using namespace MagAOX::app;
10
11SCENARIO( "streamWriter Buffer Sizing", "[streamWriter]" )
12{
13 GIVEN( "A default constructed streamWriter" )
14 {
15 WHEN( "default configurations" )
16 {
17 size_t maxCircBuffLength = 1024;
18 double maxCircBuffSize = 2048.0;
19 size_t maxWriteChunkLength = 512;
20
21 size_t circBuffLength;
22 double circBuffSize;
23 size_t writeChunkLength;
24
25 uint32_t width = 1024;
26 uint32_t height = 1024;
27 size_t typeSize = 2;
28
30 circBuffSize,
31 writeChunkLength,
32 maxCircBuffLength,
33 maxCircBuffSize,
34 maxWriteChunkLength,
35 width,
36 height,
37 typeSize );
38
39 REQUIRE( circBuffLength == 1024 );
40 REQUIRE( circBuffSize == 2048 );
41 REQUIRE( writeChunkLength == 512 );
42 }
43
44 WHEN( "larger frame size using all of max size" )
45 {
46 size_t maxCircBuffLength = 1024;
47 double maxCircBuffSize = 2048.0;
48 size_t maxWriteChunkLength = 512;
49
50 size_t circBuffLength;
51 double circBuffSize;
52 size_t writeChunkLength;
53
54 uint32_t width = 2048;
55 uint32_t height = 2048;
56 size_t typeSize = 2;
57
59 circBuffSize,
60 writeChunkLength,
61 maxCircBuffLength,
62 maxCircBuffSize,
63 maxWriteChunkLength,
64 width,
65 height,
66 typeSize );
67
68 REQUIRE( circBuffLength == 256 );
69 REQUIRE( circBuffSize == 2048 );
70 REQUIRE( writeChunkLength == 128 );
71 }
72
73 WHEN( "largest frame size possible using all of max size" )
74 {
75 size_t maxCircBuffLength = 1024;
76 double maxCircBuffSize = 1024.0;
77 size_t maxWriteChunkLength = 512;
78
79 size_t circBuffLength;
80 double circBuffSize;
81 size_t writeChunkLength;
82
83 uint32_t width = 16384;
84 uint32_t height = 16384;
85 size_t typeSize = 2;
86
88 circBuffSize,
89 writeChunkLength,
90 maxCircBuffLength,
91 maxCircBuffSize,
92 maxWriteChunkLength,
93 width,
94 height,
95 typeSize );
96
97 REQUIRE( circBuffLength == 2 );
98 REQUIRE( circBuffSize == 1024 );
99 REQUIRE( writeChunkLength == 1 );
100 }
101
102 WHEN( "Exceeding largest frame size possible" )
103 {
104 size_t maxCircBuffLength = 1024;
105 double maxCircBuffSize = 1024.0;
106 size_t maxWriteChunkLength = 512;
107
108 size_t circBuffLength;
109 double circBuffSize;
110 size_t writeChunkLength;
111
112 uint32_t width = 16385;
113 uint32_t height = 16385;
114 size_t typeSize = 2;
115
116 streamWriter::getCircBuffLengths( circBuffLength,
117 circBuffSize,
118 writeChunkLength,
119 maxCircBuffLength,
120 maxCircBuffSize,
121 maxWriteChunkLength,
122 width,
123 height,
124 typeSize );
125
126 REQUIRE( circBuffLength == 1 );
127 REQUIRE_THAT( circBuffSize, Catch::Matchers::WithinAbs( 512.0625019, 0.00001 ) );
128 REQUIRE( writeChunkLength == 1 );
129 }
130
131 WHEN( "Exceeding largest frame size possible by a lot" )
132 {
133 size_t maxCircBuffLength = 1024;
134 double maxCircBuffSize = 1024.0;
135 size_t maxWriteChunkLength = 512;
136
137 size_t circBuffLength;
138 double circBuffSize;
139 size_t writeChunkLength;
140
141 uint32_t width = 56385;
142 uint32_t height = 56385;
143 size_t typeSize = 2;
144
145 streamWriter::getCircBuffLengths( circBuffLength,
146 circBuffSize,
147 writeChunkLength,
148 maxCircBuffLength,
149 maxCircBuffSize,
150 maxWriteChunkLength,
151 width,
152 height,
153 typeSize );
154
155 REQUIRE( circBuffLength == 0 );
156 REQUIRE( circBuffSize == 0 );
157 REQUIRE( writeChunkLength == 0 );
158 }
159
160 WHEN( "LOWFS-like setup, 32x32 frames" )
161 {
162 size_t maxCircBuffLength = 524288;
163 double maxCircBuffSize = 1024.0;
164 size_t maxWriteChunkLength = 16384;
165
166 size_t circBuffLength;
167 double circBuffSize;
168 size_t writeChunkLength;
169
170 uint32_t width = 32;
171 uint32_t height = 32;
172 size_t typeSize = 2;
173
174 streamWriter::getCircBuffLengths( circBuffLength,
175 circBuffSize,
176 writeChunkLength,
177 maxCircBuffLength,
178 maxCircBuffSize,
179 maxWriteChunkLength,
180 width,
181 height,
182 typeSize );
183
184 REQUIRE( circBuffLength == 524288 );
185 REQUIRE_THAT( circBuffSize, Catch::Matchers::WithinAbs( 1024, 0.00001 ) );
186 REQUIRE( writeChunkLength == 16384 );
187 REQUIRE( ( circBuffLength % writeChunkLength ) == 0 );
188 }
189
190 WHEN( "LOWFS-like setup, 512x512 frames" )
191 {
192 size_t maxCircBuffLength = 524288;
193 double maxCircBuffSize = 1024.0;
194 size_t maxWriteChunkLength = 16384;
195
196 size_t circBuffLength;
197 double circBuffSize;
198 size_t writeChunkLength;
199
200 uint32_t width = 512;
201 uint32_t height = 512;
202 size_t typeSize = 2;
203
204 streamWriter::getCircBuffLengths( circBuffLength,
205 circBuffSize,
206 writeChunkLength,
207 maxCircBuffLength,
208 maxCircBuffSize,
209 maxWriteChunkLength,
210 width,
211 height,
212 typeSize );
213
214 REQUIRE( circBuffLength == 2048 );
215 REQUIRE_THAT( circBuffSize, Catch::Matchers::WithinAbs( 1024, 0.00001 ) );
216 REQUIRE( writeChunkLength == 64 );
217 REQUIRE( ( circBuffLength % writeChunkLength ) == 0 );
218 }
219
220 WHEN( "LOWFS-like setup, 3200x3200 frames" )
221 {
222 size_t maxCircBuffLength = 524288;
223 double maxCircBuffSize = 1024.0;
224 size_t maxWriteChunkLength = 16384;
225
226 size_t circBuffLength;
227 double circBuffSize;
228 size_t writeChunkLength;
229
230 uint32_t width = 3200;
231 uint32_t height = 3200;
232 size_t typeSize = 2;
233
234 streamWriter::getCircBuffLengths( circBuffLength,
235 circBuffSize,
236 writeChunkLength,
237 maxCircBuffLength,
238 maxCircBuffSize,
239 maxWriteChunkLength,
240 width,
241 height,
242 typeSize );
243
244 REQUIRE( circBuffLength == 52 );
245 REQUIRE_THAT( circBuffSize, Catch::Matchers::WithinAbs( 1015.625, 0.00001 ) );
246 REQUIRE( writeChunkLength == 1 );
247 REQUIRE( ( circBuffLength % writeChunkLength ) == 0 );
248 }
249 }
250}
#define GIVEN(desc)
Definition catch.hpp:17763
#define WHEN(desc)
Definition catch.hpp:17765
#define REQUIRE_THAT(arg, matcher)
Definition catch.hpp:17704
#define SCENARIO(...)
Definition catch.hpp:17760
#define REQUIRE(...)
Definition catch.hpp:17676
static void getCircBuffLengths(size_t &circBuffLength, double &circBuffSize, size_t &writeChunkLength, size_t maxCircBuffLength, double maxCircBuffSize, size_t maxWriteChunkLength, uint32_t width, uint32_t height, size_t typeSize)
Floating::WithinAbsMatcher WithinAbs(double target, double margin)