37#include "ramCanvas.hpp"
66#define DO_INTRP_AVG9 0
67#define DO_INTRP_BILN 0
86 typedef mjr::ramCanvas3c8b canvasType;
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;
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;
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++)
119 theRamCanvas.drawPoint(x, y, aColor);
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;
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;
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;
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;
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++)
170 theRamCanvas.drawPointNC(x, y, aColor);
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;
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;
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++) {
197 cColor.setChans_byte(
static_cast<uint8_t
>((i+x)%256));
199 cColor.setChans_byte(
static_cast<uint8_t
>((i+y)%256));
200 theRamCanvas.drawPointNC(x, y, cColor);
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;
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);
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;
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;
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++)
242 theRamCanvas.getPxColorRefNC(x, y).tfrmMinI(bColor);
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;
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++) {
256 theRamCanvas.clrCanvasToWhite();
258 theRamCanvas.clrCanvasToBlack();
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;
266 std::cout <<
"Starting DO_CLR" << std::endl;
267 bmStartTime = std::chrono::system_clock::now();
268 for(
int i=0;i<REPS*256;i++) {
270 theRamCanvas.clrCanvas(aColor);
272 theRamCanvas.clrCanvas(bColor);
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;
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));
288 theRamCanvas.drawLine(-x1+xMax/2, -y1+yMax/2, x1+xMax/2, y1+yMax/2, aColor);
290 theRamCanvas.drawLine(-x1+xMax/2, -y1+yMax/2, x1+xMax/2, y1+yMax/2, bColor);
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;
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)
305 theRamCanvas.drawLine(0, y, xMax, yMax-y, aColor);
307 theRamCanvas.drawLine(0, y, xMax, yMax-y, bColor);
308 for(
int x=0;x<=xMax;x+=1)
310 theRamCanvas.drawLine(x, 0, xMax-x, yMax, aColor);
312 theRamCanvas.drawLine(x, 0, xMax-x, yMax, bColor);
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;
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)
325 theRamCanvas.drawFillTriangle(xMax/2, 0, 0, y, xMax, yMax-y, aColor, bColor, dColor);
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;
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)
339 theRamCanvas.drawFillTriangle(xMax/2, 0, 0, y, xMax, yMax-y, aColor);
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;
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++)
353 theRamCanvas.drawFillTriangle(x1, yMax/2, x1+BSIZE/2, yMax/2+x1, x1+BSIZE/2, yMax/2-x1, aColor, bColor, dColor);
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;
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++)
367 theRamCanvas.drawFillTriangle(x1, yMax/2, x1+BSIZE/2, yMax/2+x1, x1+BSIZE/2, yMax/2-x1, aColor);
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;
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++)
381 theRamCanvas.drawCircle(xy, xy, xMax-xy, aColor);
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;
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++)
395 theRamCanvas.drawFillRectangle(xy, xy, xMax-xy, yMax-xy, aColor);
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;
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)
409 theRamCanvas.drawHorzLineNC(0, xMax, y, aColor);
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;
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++)
423 theRamCanvas.drawLine(0, y, xMax, y, aColor);
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;
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++)
437 theRamCanvas.drawLine(x, 0, x, yMax, aColor);
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;
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++)
451 theRamCanvas.drawVertLineNC(0, yMax, x, aColor);
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;
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++)
465 theRamCanvas.drawLine(0, y, xMax, xMax+y, aColor);
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;
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;
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;
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;
509 std::cout <<
"Starting DO_CONV" << std::endl;
510 double kernel[10*10];
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;
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;
528 std::cout <<
"Starting DO_OUT_TIF" << std::endl;
529 theRamCanvas.writeTIFFfile(
"bmark.tiff");
533 std::cout <<
"Starting DO_OUT_RAW" << std::endl;
534 theRamCanvas.writeRAWfile(
"bmark.mrw");
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;
int main(int argc, char *argv[])