#include #include #include #include int main() { static const char message[] = "This is the message that is copied around " "and around. The whole point is that I will " "create a QByteArray object or a const char* " "to hold this, then copy it, then delete it.\n" "No more, no less"; static const int len = sizeof message; QTime timer; timer.start(); for (int i = 0; i < 1000; ++i) { char *ptr = new char[len]; memcpy(ptr, message, len); delete[] ptr; } qDebug() << timer.elapsed(); timer.start(); for (int i = 0; i < 1000; ++i) { QByteArray array(message, len - 1); } qDebug() << timer.elapsed(); }