Changes

Jump to: navigation, search

Savy Cat

3,797 bytes added, 21:43, 27 March 2018
Profiling With gprof
==== Profiling With gprof ====
At last we can measure performance. Giving Rotate90.exe an initial run:
[[File:Gprof-run1.png|400px500px]]
During the run, Tiny_Shay completed seemingly instantly. Medium_Shay had a slightly noticeable latency, but seemed to be less than a second. Large_Shay took a noticeable amount of time, at least a couple seconds.
0.00 4.12 0.00 33 0.00 0.00 cimg_library::cimg::strcasecmp(char const*, char const*)
...</nowiki>
 
At this point I decide to modify Rotate.cpp to accept a filename as command line argument, and perform Rotate90x4 (x3) for each file individually:
 
<nowiki>
// Evan Marinzel - DPS915 Project
// Rotate.cpp
 
#include "Rotate.h"
 
int main(int argc, char** argv) {
 
if (argc != 2) {
std::cerr << argv[0] << ": invalid number of arguments\n";
std::cerr << "Usage: " << argv[0] << " image.jpg\n";
return 1;
}
 
// Allocate memory for CImg structure, initializing colour values from speficied file.
cimg_library::CImg<PX_TYPE> img(argv[1]);
 
// Allocate memory for rotated versions of above, initializing colour values to 0.
cimg_library::CImg<PX_TYPE> img_90(img.height(), img.width(), 1, 3, 0);
 
// Display image statistics and rotate 12 times.
imgStats(argv[1], img);
std::cout << "Rotating 4x..." << std::endl;
rotate90x4(img, img_90);
std::cout << "Rotating 8x..." << std::endl;
rotate90x4(img, img_90);
std::cout << "Rotating 12x..." << std::endl;
rotate90x4(img, img_90);
std::cout << argv[1] << " is dizzy!" << std::endl << std::endl;
 
return 0;
 
}</nowiki>
 
After a quick search, I find that the sample rate of gprof is determined by the OS and we cannot increase it past 0.01 seconds.
 
Here is Tiny Shay. In this case, "no time accumulated":
 
<nowiki>Each sample counts as 0.01 seconds.
no time accumulated
 
% cumulative self self total
time seconds seconds calls Ts/call Ts/call name
0.00 0.00 0.00 12 0.00 0.00 rotate90(cimg_library::CImg<unsigned char>, cimg_library::CImg<unsigned char>&)
0.00 0.00 0.00 12 0.00 0.00 cimg_library::CImg<unsigned char>::CImg(cimg_library::CImg<unsigned char> const&)
0.00 0.00 0.00 11 0.00 0.00 cimg_library::cimg::strcasecmp(char const*, char const*)
...</nowiki>
 
Medium Shay:
 
<nowiki>Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls ms/call ms/call name
94.44 0.34 0.34 12 28.33 28.33 rotate90(cimg_library::CImg<unsigned char>, cimg_library::CImg<unsigned char>&)
5.56 0.36 0.02 1 20.00 20.00 cimg_library::CImg<unsigned char>::_load_pnm(_IO_FILE*, char const*)
0.00 0.36 0.00 12 0.00 0.00 cimg_library::CImg<unsigned char>::CImg(cimg_library::CImg<unsigned char> const&)
...</nowiki>
 
Large Shay:
 
<nowiki>Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls ms/call ms/call name
98.11 3.63 3.63 12 302.50 302.50 rotate90(cimg_library::CImg<unsigned char>, cimg_library::CImg<unsigned char>&)
1.89 3.70 0.07 1 70.00 70.00 cimg_library::CImg<unsigned char>::_load_pnm(_IO_FILE*, char const*)
0.00 3.70 0.00 12 0.00 0.00 cimg_library::CImg<unsigned char>::CImg(cimg_library::CImg<unsigned char> const&)
...</nowiki>
 
For the sake of science, I created Huge-Shay.jpg (6528px x 4896px), which is double the dimensions of Large Shay, requiring 95,883,264 value assignments.
 
<nowiki>Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
98.31 20.31 20.31 12 1.69 1.69 rotate90(cimg_library::CImg<unsigned char>, cimg_library::CImg<unsigned char>&)
1.69 20.66 0.35 1 0.35 0.35 cimg_library::CImg<unsigned char>::_load_pnm(_IO_FILE*, char const*)
0.00 20.66 0.00 12 0.00 0.00 cimg_library::CImg<unsigned char>::CImg(cimg_library::CImg<unsigned char> const&)
...</nowiki>
=== Assignment 2 ===
=== Assignment 3 ===
93
edits

Navigation menu