Skip to content

Instantly share code, notes, and snippets.

@mnutt
Created October 30, 2011 20:40
Show Gist options
  • Save mnutt/1326410 to your computer and use it in GitHub Desktop.
Save mnutt/1326410 to your computer and use it in GitHub Desktop.
benchmark QImage save
#include <QtGui>
#include <QTimer>
int
main(int argc, char *argv[]) {
int times = 1000;
QString format("png");
QByteArray ba;
QBuffer* buffer = new QBuffer(&ba);
buffer->open(QIODevice::WriteOnly);
QTime timer;
timer.start();
while(times--) {
QImage image(800, 800, QImage::Format_RGB32);
image.save(buffer, format.toAscii(), -1);
}
int elapsed = timer.elapsed();
qDebug() << "Completed 1000 runs in" << elapsed << "ms. (" << (elapsed / 1000) << "ms / render )";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment