Created
November 21, 2010 10:15
-
-
Save wimleers/708621 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------------------------------------------- | |
# | |
# Project created by QtCreator 2010-11-20T18:00:03 | |
# | |
#------------------------------------------------- | |
QT += core | |
QT -= gui | |
TARGET = DateTimeFromStringPerfTest | |
CONFIG += console | |
CONFIG -= app_bundle | |
TEMPLATE = app | |
SOURCES += main.cpp | |
HEADERS += \ | |
QCachingLocale.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <QDateTime> | |
#include <QTime> | |
#include <QTextStream> | |
#include <QDebug> | |
#include "QCachingLocale.h" | |
#define NUM_CALLS 1000 | |
void parseDate(QTextStream & cout) { | |
QTime timer; | |
timer.start(); | |
for (int i = 0; i < NUM_CALLS; i++) | |
QDateTime::fromString("16-Nov-2010 16:10:00", "dd-MMM-yyyy HH:mm:ss"); | |
cout << timer.elapsed() << " ms were necessary for parsing the date " << NUM_CALLS<< " times." << endl; | |
} | |
int main(int argc, char *argv[]) { | |
QTextStream cout(stdout); | |
cout << "Without QCachingLocale:" << endl; | |
parseDate(cout); | |
cout << endl << "With QCachingLocale:" << endl; | |
QCachingLocale cl; | |
parseDate(cout); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Without QCachingLocale: | |
4839 ms were necessary for parsing the date 1000 times. | |
With QCachingLocale: | |
23 ms were necessary for parsing the date 1000 times. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment