ofImage::clone vs ofImage::operator=

Hi, I would like to know if there’s any benefit of using ofImage::clone over simply copying with operator ‘=’

When I measure CPU time, there was almost no difference between two.

So I wonder if there’s any benefit of using ofImage::clone than just simple ‘=’ ?

Here’s my test code


std::clock_t startcputime = std::clock();

image2.clone(image1); //option1
image2 = image1; //option2

double cpu_duration = (std::clock() - startcputime) / (double)CLOCKS_PER_SEC;
std::cout << "Finished in " << cpu_duration << " seconds [CPU Clock] " << std::endl;

EDIT: when I loop 1000 times, clone seemed to be always slightly faster than '='
So maybe this could be the only benefit?

operator= as well as the copy constructors just call clone internaly so any time difference is negligible. clone should probably be private since we don’t have such method anywhere else

1 Like

Thank you @arturo