MRaster examples 21.0.0.0
Image Processing Library
Loading...
Searching...
No Matches
bmark.cpp
Go to the documentation of this file.
1// -*- Mode:C++; Coding:us-ascii-unix; fill-column:158 -*-
2/*******************************************************************************************************************************************************.H.S.**/
3/**
4 @file bmark.cpp
5 @author Mitch Richling <https://www.mitchr.me>
6 @brief Benchmark program for pixel draw rates with ramCanvas.@EOL
7 @copyright
8 @parblock
9 Copyright (c) 1988-2015, Mitchell Jay Richling <https://www.mitchr.me> All rights reserved.
10
11 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer.
14
15 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17
18 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software
19 without specific prior written permission.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26 DAMAGE.
27 @endparblock
28 @filedetails
29
30 Simple benchmark. Select what you want to test via the define statements.
31
32*/
33/*******************************************************************************************************************************************************.H.E.**/
34/** @cond exj */
35
36//--------------------------------------------------------------------------------------------------------------------------------------------------------------
37#include "ramCanvas.hpp"
38
39//--------------------------------------------------------------------------------------------------------------------------------------------------------------
40#define DO_POINT 0
41#define DO_POINT_NC 0
42#define DO_RAMP 0
43#define DO_RAMP_INT 0
44#define DO_RAMP_CON 0
45#define DO_INVERT 0
46#define DO_COL_SET 0
47#define DO_COL_SETC 0
48#define DO_UNPACK 0
49#define DO_MINI 0
50#define DO_CLR_BLK 0
51#define DO_CLR 0
52#define DO_FFBTRI 0
53#define DO_FFTRI 0
54#define DO_FGBTRI 0
55#define DO_FGTRI 0
56#define DO_CIRCLE 1
57#define DO_RECT 0
58#define DO_LINE 0
59#define DO_CLIP_LINE 0
60#define DO_HLINE_NC 0
61#define DO_HLINE 0
62#define DO_VLINE_NC 0
63#define DO_VLINE 0
64#define DO_45LINE 0
65#define DO_TRIVLN 0
66#define DO_INTRP_AVG9 0
67#define DO_INTRP_BILN 0
68#define DO_CONV 0
69#define DO_CS_CONV 0
70
71#define DO_OUT_TIF 1
72#define DO_OUT_RAW 0
73
74#define REPS 1
75
76#define BSIZE 4048
77//#define BSIZE 10
78
79//--------------------------------------------------------------------------------------------------------------------------------------------------------------
80// typedef mjr::ramCanvas1c8b canvasType;
81// typedef mjr::ramCanvas1c16b canvasType;
82// typedef mjr::ramCanvas1c32b canvasType;
83// typedef mjr::ramCanvas1c64b canvasType;
84// typedef mjr::ramCanvas1c128b canvasType;
85
86 typedef mjr::ramCanvas3c8b canvasType;
87// typedef mjr::ramCanvas3c16b canvasType;
88// typedef mjr::ramCanvas3c32b canvasType;
89
90// typedef mjr::ramCanvas3c32F canvasType;
91// typedef mjr::ramCanvas3c64F canvasType;
92
93// typedef mjr::ramCanvas8c8b canvasType;
94
95//--------------------------------------------------------------------------------------------------------------------------------------------------------------
96int main(void) {
97 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
98 canvasType theRamCanvas(BSIZE, BSIZE);
99 int xMax = theRamCanvas.getNumPixX()-1;
100 int yMax = theRamCanvas.getNumPixY()-1;
101 canvasType::colorType aColor("red");
102 canvasType::colorType bColor("cyan");
103 canvasType::colorType cColor("black");
104 canvasType::colorType dColor("green");
105 std::chrono::time_point<std::chrono::system_clock> bmStartTime, bmEndTime;
106 std::chrono::duration<double> bmTime;
107
108 std::cout << "bpp: " << canvasType::colorType::bitsPerPixel << std::endl;
109 std::cout << "chn: " << canvasType::colorType::channelCount << std::endl;
110 std::cout << "int: " << canvasType::colorType::chanIsInt << std::endl;
111
112#if DO_POINT
113 std::cout << "Starting DO_POINT" << std::endl;
114 bmStartTime = std::chrono::system_clock::now();
115 for(int i=0;i<REPS*256;i++)
116 for(int y=0;y<=xMax;y++)
117 for(int x=0;x<=yMax;x++)
118 if((x*y)%2)
119 theRamCanvas.drawPoint(x, y, aColor);
120 else
121 theRamCanvas.drawPoint(x, y, bColor);
122 bmEndTime = std::chrono::system_clock::now();
123 bmTime = std::chrono::system_clock::now() - bmStartTime;
124 std::cout << " DO_POINT Runtime " << bmTime.count() << " sec" << std::endl;
125#endif
126
127#if DO_RAMP_INT
128 std::cout << "Starting DO_RAMP_INT" << std::endl;
129 bmStartTime = std::chrono::system_clock::now();
130 for(int i=0;i<REPS*32;i++)
131 for(int y=0;y<=xMax;y++)
132 for(int x=0;x<=yMax;x++)
133 theRamCanvas.drawPoint(x, y, cColor.cmpRGBcornerDGradiant(x+y, "0BCGYWMR0"));
134 bmEndTime = std::chrono::system_clock::now();
135 bmTime = std::chrono::system_clock::now() - bmStartTime;
136 std::cout << " DO_RAMP_INT Runtime " << bmTime.count() << " sec" << std::endl;
137#endif
138
139#if DO_RAMP_CON
140 std::cout << "Starting DO_RAMP_CON" << std::endl;
141 bmStartTime = std::chrono::system_clock::now();
142 for(int i=0;i<REPS*32;i++)
143 for(int y=0;y<=xMax;y++)
144 for(int x=0;x<=yMax;x++)
145 theRamCanvas.drawPoint(x, y, cColor.cmpRGBcornerCGradiant(1.0*(x+y)/(yMax+yMax), "0BCGYWMR0"));
146 bmEndTime = std::chrono::system_clock::now();
147 bmTime = std::chrono::system_clock::now() - bmStartTime;
148 std::cout << " DO_RAMP_CON Runtime " << bmTime.count() << " sec" << std::endl;
149#endif
150
151#if DO_RAMP
152 std::cout << "Starting DO_RAMP" << std::endl;
153 bmStartTime = std::chrono::system_clock::now();
154 for(int i=0;i<REPS*16;i++)
155 for(int y=0;y<=xMax;y++)
156 for(int x=0;x<=yMax;x++)
157 theRamCanvas.drawPoint(x, y, cColor.linearInterpolate(x/(double)xMax, aColor, bColor));
158 bmEndTime = std::chrono::system_clock::now();
159 bmTime = std::chrono::system_clock::now() - bmStartTime;
160 std::cout << " DO_RAMP Runtime " << bmTime.count() << " sec" << std::endl;
161#endif
162
163#if DO_POINT_NC
164 std::cout << "Starting DO_POINT_NC" << std::endl;
165 bmStartTime = std::chrono::system_clock::now();
166 for(int i=0;i<REPS*512;i++)
167 for(int y=0;y<=xMax;y++)
168 for(int x=0;x<=yMax;x++)
169 if((x*y)%2)
170 theRamCanvas.drawPointNC(x, y, aColor);
171 else
172 theRamCanvas.drawPointNC(x, y, bColor);
173 bmEndTime = std::chrono::system_clock::now();
174 bmTime = std::chrono::system_clock::now() - bmStartTime;
175 std::cout << " DO_POINT_NC Runtime " << bmTime.count() << " sec" << std::endl;
176#endif
177
178#if DO_INVERT
179 std::cout << "Starting DO_INVERT" << std::endl;
180 bmStartTime = std::chrono::system_clock::now();
181 for(int i=0;i<REPS*128+1;i++)
182 for(int y=0;y<=xMax;y++)
183 for(int x=0;x<=yMax;x++)
184 theRamCanvas.getPxColorRefNC(x, y).tfrmInvert();
185 bmEndTime = std::chrono::system_clock::now();
186 bmTime = std::chrono::system_clock::now() - bmStartTime;
187 std::cout << " DO_INVERT Runtime " << bmTime.count() << " sec" << std::endl;
188#endif
189
190#if DO_COL_SETC
191 std::cout << "Starting DO_COL_SETC" << std::endl;
192 bmStartTime = std::chrono::system_clock::now();
193 for(int i=0;i<REPS*32;i++)
194 for(int y=0;y<=xMax;y++)
195 for(int x=0;x<=yMax;x++) {
196 if((i+x*y)%2)
197 cColor.setChans_byte(static_cast<uint8_t>((i+x)%256));
198 else
199 cColor.setChans_byte(static_cast<uint8_t>((i+y)%256));
200 theRamCanvas.drawPointNC(x, y, cColor);
201 }
202 bmEndTime = std::chrono::system_clock::now();
203 bmTime = std::chrono::system_clock::now() - bmStartTime;
204 std::cout << " DO_COL_SETC Runtime " << bmTime.count() << " sec" << std::endl;
205#endif
206
207#if DO_COL_SET
208 std::cout << "Starting DO_COL_SET" << std::endl;
209 bmStartTime = std::chrono::system_clock::now();
210 for(int i=0;i<REPS*32;i++)
211 for(int y=0;y<=xMax;y++)
212 for(int x=0;x<=yMax;x++) {
213 cColor.setChansRGB_byte(static_cast<uint8_t>(x%256),
214 static_cast<uint8_t>(y%256),
215 static_cast<uint8_t>((i*8)%256));
216 theRamCanvas.drawPointNC(x, y, cColor);
217 }
218 bmEndTime = std::chrono::system_clock::now();
219 bmTime = std::chrono::system_clock::now() - bmStartTime;
220 std::cout << " DO_COL_SET Runtime " << bmTime.count() << " sec" << std::endl;
221#endif
222
223#if DO_UNPACK
224 std::cout << "Starting DO_UNPACK" << std::endl;
225 bmStartTime = std::chrono::system_clock::now();
226 for(int i=0;i<REPS*64;i++)
227 for(int y=0;y<=xMax;y++)
228 for(int x=0;x<=yMax;x++)
229 theRamCanvas.getPxColorRefNC(x, y).setRGBfromLogPackIntARGB(0xFFFFFF-i*x*x*y);
230 bmEndTime = std::chrono::system_clock::now();
231 bmTime = std::chrono::system_clock::now() - bmStartTime;
232 std::cout << " DO_UNPACK Runtime " << bmTime.count() << " sec" << std::endl;
233#endif
234
235#if DO_MINI
236 std::cout << "Starting DO_MINI" << std::endl;
237 bmStartTime = std::chrono::system_clock::now();
238 for(int i=0;i<REPS*128;i++)
239 for(int y=0;y<=xMax;y++)
240 for(int x=0;x<=yMax;x++)
241 if((x*y)%2)
242 theRamCanvas.getPxColorRefNC(x, y).tfrmMinI(bColor);
243 else
244 theRamCanvas.getPxColorRefNC(x, y).tfrmMinI(bColor);
245 bmEndTime = std::chrono::system_clock::now();
246 bmTime = std::chrono::system_clock::now() - bmStartTime;
247 std::cout << " DO_MINI Runtime " << bmTime.count() << " sec" << std::endl;
248#endif
249
250#if DO_CLR_BLK
251 std::cout << "Starting DO_CLR_BLK" << std::endl;
252 bmStartTime = std::chrono::system_clock::now();
253 theRamCanvas.setDfltColor(aColor);
254 for(int i=0;i<REPS*256;i++) {
255 if(i%2)
256 theRamCanvas.clrCanvasToWhite();
257 else
258 theRamCanvas.clrCanvasToBlack();
259 }
260 bmEndTime = std::chrono::system_clock::now();
261 bmTime = std::chrono::system_clock::now() - bmStartTime;
262 std::cout << " DO_CLR_BLK Runtime " << bmTime.count() << " sec" << std::endl;
263#endif
264
265#if DO_CLR
266 std::cout << "Starting DO_CLR" << std::endl;
267 bmStartTime = std::chrono::system_clock::now();
268 for(int i=0;i<REPS*256;i++) {
269 if(i%2)
270 theRamCanvas.clrCanvas(aColor);
271 else
272 theRamCanvas.clrCanvas(bColor);
273 }
274 bmEndTime = std::chrono::system_clock::now();
275 bmTime = std::chrono::system_clock::now() - bmStartTime;
276 std::cout << " DO_CLR Runtime " << bmTime.count() << " sec" << std::endl;
277#endif
278
279#if DO_CLIP_LINE
280 std::cout << "Starting DO_CLIP_LINE" << std::endl;
281 bmStartTime = std::chrono::system_clock::now();
282 for(int i=0;i<REPS*8;i++)
283 for(int j=0; j<BSIZE*4; j++) {
284 double a = static_cast<double>(j) * 6.2831 / (BSIZE * 2.0);
285 int x1 = static_cast<int>(BSIZE * std::cos(a));
286 int y1 = static_cast<int>(BSIZE * std::sin(a));
287 if(j%2)
288 theRamCanvas.drawLine(-x1+xMax/2, -y1+yMax/2, x1+xMax/2, y1+yMax/2, aColor);
289 else
290 theRamCanvas.drawLine(-x1+xMax/2, -y1+yMax/2, x1+xMax/2, y1+yMax/2, bColor);
291 }
292 bmEndTime = std::chrono::system_clock::now();
293 bmTime = std::chrono::system_clock::now() - bmStartTime;
294 std::cout << " DO_CLIP_LINE Runtime " << bmTime.count() << " sec" << std::endl;
295#endif
296
297// MJR TODO NOTE <2022-06-18> main: Add a test case for lines that are completely out of the drawing area.
298
299#if DO_LINE
300 std::cout << "Starting DO_LINE" << std::endl;
301 bmStartTime = std::chrono::system_clock::now();
302 for(int i=0;i<REPS*16;i++) {
303 for(int y=0;y<=yMax;y+=1)
304 if(y%2)
305 theRamCanvas.drawLine(0, y, xMax, yMax-y, aColor);
306 else
307 theRamCanvas.drawLine(0, y, xMax, yMax-y, bColor);
308 for(int x=0;x<=xMax;x+=1)
309 if(x%2)
310 theRamCanvas.drawLine(x, 0, xMax-x, yMax, aColor);
311 else
312 theRamCanvas.drawLine(x, 0, xMax-x, yMax, bColor);
313 }
314 bmEndTime = std::chrono::system_clock::now();
315 bmTime = std::chrono::system_clock::now() - bmStartTime;
316 std::cout << " DO_LINE Runtime " << bmTime.count() << " sec" << std::endl;
317#endif
318
319#if DO_FFBTRI
320 std::cout << "Starting DO_FFBTRI" << std::endl;
321 bmStartTime = std::chrono::system_clock::now();
322 for(int i=0;i<REPS;i++)
323 for(int y=0;y<=yMax;y+=50)
324 if(y%2)
325 theRamCanvas.drawFillTriangle(xMax/2, 0, 0, y, xMax, yMax-y, aColor, bColor, dColor);
326 else
327 theRamCanvas.drawFillTriangle(xMax/2, 0, 0, y, xMax, yMax-y, bColor, cColor, aColor);
328 bmEndTime = std::chrono::system_clock::now();
329 bmTime = std::chrono::system_clock::now() - bmStartTime;
330 std::cout << " DO_FFBTRI Runtime " << bmTime.count() << " sec" << std::endl;
331#endif
332
333#if DO_FFTRI
334 std::cout << "Starting DO_FFTRI" << std::endl;
335 bmStartTime = std::chrono::system_clock::now();
336 for(int i=0;i<REPS*2;i++)
337 for(int y=0;y<=yMax;y+=25)
338 if(y%2)
339 theRamCanvas.drawFillTriangle(xMax/2, 0, 0, y, xMax, yMax-y, aColor);
340 else
341 theRamCanvas.drawFillTriangle(xMax/2, 0, 0, y, xMax, yMax-y, bColor);
342 bmEndTime = std::chrono::system_clock::now();
343 bmTime = std::chrono::system_clock::now() - bmStartTime;
344 std::cout << " DO_FFTRI Runtime " << bmTime.count() << " sec" << std::endl;
345#endif
346
347#if DO_FGBTRI
348 std::cout << "Starting DO_FGBTRI" << std::endl;
349 bmStartTime = std::chrono::system_clock::now();
350 for(int i=0;i<REPS*2;i++)
351 for(int x1=xMax,j=0;x1>=0;x1-=BSIZE/64,j++)
352 if(j%2)
353 theRamCanvas.drawFillTriangle(x1, yMax/2, x1+BSIZE/2, yMax/2+x1, x1+BSIZE/2, yMax/2-x1, aColor, bColor, dColor);
354 else
355 theRamCanvas.drawFillTriangle(x1, yMax/2, x1+BSIZE/2, yMax/2+x1, x1+BSIZE/2, yMax/2-x1, bColor, cColor, aColor);
356 bmEndTime = std::chrono::system_clock::now();
357 bmTime = std::chrono::system_clock::now() - bmStartTime;
358 std::cout << " DO_FGBTRI Runtime " << bmTime.count() << " sec" << std::endl;
359#endif
360
361#if DO_FGTRI
362 std::cout << "Starting DO_FGTRI" << std::endl;
363 bmStartTime = std::chrono::system_clock::now();
364 for(int i=0;i<REPS*16;i++)
365 for(int x1=xMax,j=0;x1>=0;x1-=BSIZE/128,j++)
366 if(j%2)
367 theRamCanvas.drawFillTriangle(x1, yMax/2, x1+BSIZE/2, yMax/2+x1, x1+BSIZE/2, yMax/2-x1, aColor);
368 else
369 theRamCanvas.drawFillTriangle(x1, yMax/2, x1+BSIZE/2, yMax/2+x1, x1+BSIZE/2, yMax/2-x1, bColor);
370 bmEndTime = std::chrono::system_clock::now();
371 bmTime = std::chrono::system_clock::now() - bmStartTime;
372 std::cout << " DO_FGTRI Runtime " << bmTime.count() << " sec" << std::endl;
373#endif
374
375#if DO_CIRCLE
376 std::cout << "Starting DO_CIRCLE" << std::endl;
377 bmStartTime = std::chrono::system_clock::now();
378 for(int i=0;i<REPS*16;i++)
379 for(int xy=100, j=0;xy<yMax && xy<=xMax;xy+=1, j++)
380 if(j%2)
381 theRamCanvas.drawCircle(xy, xy, xMax-xy, aColor);
382 else
383 theRamCanvas.drawCircle(xy, xy, xMax-xy, bColor);
384 bmEndTime = std::chrono::system_clock::now();
385 bmTime = std::chrono::system_clock::now() - bmStartTime;
386 std::cout << " DO_CIRCLE Runtime " << bmTime.count() << " sec" << std::endl;
387#endif
388
389#if DO_RECT
390 std::cout << "Starting DO_RECT" << std::endl;
391 bmStartTime = std::chrono::system_clock::now();
392 for(int i=0;i<REPS*16;i++)
393 for(int xy=0, j=0;xy<yMax && xy<=xMax;xy+=BSIZE/128, j++)
394 if(j%2)
395 theRamCanvas.drawFillRectangle(xy, xy, xMax-xy, yMax-xy, aColor);
396 else
397 theRamCanvas.drawFillRectangle(xy, xy, xMax-xy, yMax-xy, bColor);
398 bmEndTime = std::chrono::system_clock::now();
399 bmTime = std::chrono::system_clock::now() - bmStartTime;
400 std::cout << " DO_RECT Runtime " << bmTime.count() << " sec" << std::endl;
401#endif
402
403#if DO_HLINE_NC
404 std::cout << "Starting DO_HLINE_NC" << std::endl;
405 bmStartTime = std::chrono::system_clock::now();
406 for(int i=0;i<REPS*512;i++)
407 for(int y=0;y<=yMax;y+=1)
408 if(y%2)
409 theRamCanvas.drawHorzLineNC(0, xMax, y, aColor);
410 else
411 theRamCanvas.drawHorzLineNC(0, xMax, y, bColor);
412 bmEndTime = std::chrono::system_clock::now();
413 bmTime = std::chrono::system_clock::now() - bmStartTime;
414 std::cout << " DO_HLINE_NC Runtime " << bmTime.count() << " sec" << std::endl;
415#endif
416
417#if DO_HLINE
418 std::cout << "Starting DO_HLINE" << std::endl;
419 bmStartTime = std::chrono::system_clock::now();
420 for(int i=0;i<REPS*128;i++)
421 for(int y=0;y<=yMax;y++)
422 if(y%2)
423 theRamCanvas.drawLine(0, y, xMax, y, aColor);
424 else
425 theRamCanvas.drawLine(0, y, xMax, y, bColor);
426 bmEndTime = std::chrono::system_clock::now();
427 bmTime = std::chrono::system_clock::now() - bmStartTime;
428 std::cout << " DO_HLINE Runtime " << bmTime.count() << " sec" << std::endl;
429#endif
430
431#if DO_VLINE
432 std::cout << "Starting DO_VLINE" << std::endl;
433 bmStartTime = std::chrono::system_clock::now();
434 for(int i=0;i<REPS*32;i++)
435 for(int x=0;x<=xMax;x++)
436 if(x%2)
437 theRamCanvas.drawLine(x, 0, x, yMax, aColor);
438 else
439 theRamCanvas.drawLine(x, 0, x, yMax, bColor);
440 bmEndTime = std::chrono::system_clock::now();
441 bmTime = std::chrono::system_clock::now() - bmStartTime;
442 std::cout << " DO_VLINE Runtime " << bmTime.count() << " sec" << std::endl;
443#endif
444
445#if DO_VLINE_NC
446 std::cout << "Starting DO_VLINE_NC" << std::endl;
447 bmStartTime = std::chrono::system_clock::now();
448 for(int i=0;i<REPS*32;i++)
449 for(int x=0;x<=xMax;x++)
450 if(x%2)
451 theRamCanvas.drawVertLineNC(0, yMax, x, aColor);
452 else
453 theRamCanvas.drawVertLineNC(0, yMax, x, bColor);
454 bmEndTime = std::chrono::system_clock::now();
455 bmTime = std::chrono::system_clock::now() - bmStartTime;
456 std::cout << " DO_VLINE_NC Runtime " << bmTime.count() << " sec" << std::endl;
457#endif
458
459#if DO_45LINE
460 std::cout << "Starting DO_45LINE" << std::endl;
461 bmStartTime = std::chrono::system_clock::now();
462 for(int i=0;i<REPS*128;i++)
463 for(int y=0;y<=yMax;y++)
464 if(y%2)
465 theRamCanvas.drawLine(0, y, xMax, xMax+y, aColor);
466 else
467 theRamCanvas.drawLine(0, y, xMax, xMax+y, bColor);
468 bmEndTime = std::chrono::system_clock::now();
469 bmTime = std::chrono::system_clock::now() - bmStartTime;
470 std::cout << " DO_45LINE Runtime " << bmTime.count() << " sec" << std::endl;
471#endif
472
473#if DO_TRIVLN
474 std::cout << "Starting DO_TRIVLN" << std::endl;
475 bmStartTime = std::chrono::system_clock::now();
476 theRamCanvas.drawLine( 0, 0, xMax/2, yMax/2, aColor);
477 theRamCanvas.drawLine(xMax/2, yMax/2, xMax, yMax, bColor);
478 theRamCanvas.autoHistStrech();
479 bmEndTime = std::chrono::system_clock::now();
480 bmTime = std::chrono::system_clock::now() - bmStartTime;
481 std::cout << " DO_TRIVLN Runtime " << bmTime.count() << " sec" << std::endl;
482#endif
483
484#if DO_INTRP_AVG9
485 std::cout << "Starting DO_INTRP_AVG9" << std::endl;
486 bmStartTime = std::chrono::system_clock::now();
487 for(int i=0;i<REPS*8;i++)
488 for(int y=0;y<=yMax;y+=1)
489 for(int x=0;x<=xMax;x+=1)
490 theRamCanvas.drawPoint(x, y, theRamCanvas.getPxColorInterpAvg9(x, y));
491 bmEndTime = std::chrono::system_clock::now();
492 bmTime = std::chrono::system_clock::now() - bmStartTime;
493 std::cout << " DO_INTRP_AVG9 Runtime " << bmTime.count() << " sec" << std::endl;
494#endif
495
496#if DO_INTRP_BILN
497 std::cout << "Starting DO_INTRP_BILN" << std::endl;
498 bmStartTime = std::chrono::system_clock::now();
499 for(int i=0;i<REPS*1;i++)
500 for(double y=0;y<=yMax;y+=0.3)
501 for(double x=0;x<=xMax;x+=0.7)
502 theRamCanvas.drawPointNC((int)x, (int)y, theRamCanvas.getPxColorInterpBLin(x, y));
503 bmEndTime = std::chrono::system_clock::now();
504 bmTime = std::chrono::system_clock::now() - bmStartTime;
505 std::cout << " DO_INTRP_BILN Runtime " << bmTime.count() << " sec" << std::endl;
506#endif
507
508#if DO_CONV
509 std::cout << "Starting DO_CONV" << std::endl;
510 double kernel[10*10];
511 int kSize = 9;
512 theRamCanvas.computeConvolutionMatrixGausian(kernel, kSize, 10);
513 bmStartTime = std::chrono::system_clock::now();
514 for(int i=0;i<REPS*2;i++)
515 theRamCanvas.convolution(kernel, kSize);
516 bmEndTime = std::chrono::system_clock::now();
517 bmTime = std::chrono::system_clock::now() - bmStartTime;
518 std::cout << " DO_CONV Runtime " << bmTime.count() << " sec" << std::endl;
519#endif
520
521 std::cout << "Benchmarks Complete" << std::endl;
522 std::cout << "Center Pixel: " << theRamCanvas.getPxColor(BSIZE/2, BSIZE/2) << std::endl;
523 std::cout << "Center Pixel C1(8-bit): " << (int)theRamCanvas.getPxColor(BSIZE/2, BSIZE/2).getC0_byte() << std::endl;
524 std::chrono::duration<double> tbmRunTime = std::chrono::system_clock::now() - startTime;
525 std::cout << "Benchmark Runtime " << tbmRunTime.count() << " sec" << std::endl;
526
527#if DO_OUT_TIF
528 std::cout << "Starting DO_OUT_TIF" << std::endl;
529 theRamCanvas.writeTIFFfile("bmark.tiff");
530#endif
531
532#if DO_OUT_RAW
533 std::cout << "Starting DO_OUT_RAW" << std::endl;
534 theRamCanvas.writeRAWfile("bmark.mrw");
535#endif
536
537 std::cout << "I/O Complete" << std::endl;
538 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
539 std::cout << "Total Runtime " << runTime.count() << " sec" << std::endl;
540}
541/** @endcond */
int main(int argc, char *argv[])