diff options
author | Mike FABIAN <mike.fabian@basyskom.de> | 2010-10-05 14:15:30 +0200 |
---|---|---|
committer | Mike FABIAN <mike.fabian@basyskom.de> | 2010-10-05 14:33:25 +0200 |
commit | 8b1c5d9b33142226ee1aa36dd549f2984b594771 (patch) | |
tree | c7e6eb8601b2d06cf5589bbf305c92149707d45f /benchmarks | |
parent | 580f03bb39306980f083821467ff521badcab857 (diff) |
Changes: add benchmark for MLocale::countryEndonym()
RevBy: Berthold Krevert
Details:
With the workaround for
http://site.icu-project.org/design/resbund/issues
RESULT : Pt_MLocale::benchmarkCountryEndonym():
0.045 msecs per iteration (total: 94, iterations: 2048)
Without this workaround:
RESULT : Pt_MLocale::benchmarkCountryEndonym():
0.015 msecs per iteration (total: 65, iterations: 4096)
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/benchmarks.pro | 1 | ||||
-rw-r--r-- | benchmarks/pt_mlocale/.gitignore | 1 | ||||
-rw-r--r-- | benchmarks/pt_mlocale/pt_mlocale.cpp | 73 | ||||
-rw-r--r-- | benchmarks/pt_mlocale/pt_mlocale.h | 49 | ||||
-rw-r--r-- | benchmarks/pt_mlocale/pt_mlocale.pro | 7 |
5 files changed, 131 insertions, 0 deletions
diff --git a/benchmarks/benchmarks.pro b/benchmarks/benchmarks.pro index 286cd88f..34ed2c44 100644 --- a/benchmarks/benchmarks.pro +++ b/benchmarks/benchmarks.pro @@ -25,6 +25,7 @@ SUBDIRS = \ pt_mprogressindicator \ pt_qapplication \ pt_mlabel \ + pt_mlocale \ pt_mslider \ pt_mstylesheet \ pt_mtheme \ diff --git a/benchmarks/pt_mlocale/.gitignore b/benchmarks/pt_mlocale/.gitignore new file mode 100644 index 00000000..282855fe --- /dev/null +++ b/benchmarks/pt_mlocale/.gitignore @@ -0,0 +1 @@ +pt_mlocale diff --git a/benchmarks/pt_mlocale/pt_mlocale.cpp b/benchmarks/pt_mlocale/pt_mlocale.cpp new file mode 100644 index 00000000..08354a73 --- /dev/null +++ b/benchmarks/pt_mlocale/pt_mlocale.cpp @@ -0,0 +1,73 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libmeegotouch. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#include "pt_mlocale.h" + +void Pt_MLocale::initTestCase() +{ + static int argc = 0; + static char *argv[1] = { (char *) "" }; + qap = new QCoreApplication(argc, argv); + QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); + QProcess process; +#ifdef HAVE_ICU + process.start("sh -c \"dpkg -s libicu44 | grep Version | perl -pe 's/^Version:[[:space:]]*([^[[:space:]]+)$/$1/g'\""); + if (!process.waitForFinished()) { + qDebug() << "cannot run process to check libicu44 package version , exiting ..."; + exit(1); + } + icuPackageVersion = process.readAllStandardOutput(); + icuPackageVersion.replace("\n", ""); + qDebug() << "libicu44 package version is:" << icuPackageVersion; +#endif +} + +void Pt_MLocale::cleanupTestCase() +{ + delete qap; +} + +void Pt_MLocale::init() +{ +} + +void Pt_MLocale::cleanup() +{ +} + +void Pt_MLocale::benchmarkCountryEndonym() +{ + QString language("de_CH"); // only this should matter + QString lcMessages("en_US"); // should not matter + QString lcTime("ar_SA"); // should not matter + QString lcNumeric("en_US"); // should not matter + MLocale locale(language); + locale.setCategoryLocale(MLocale::MLcMessages, lcMessages); + locale.setCategoryLocale(MLocale::MLcTime, lcTime); + locale.setCategoryLocale(MLocale::MLcNumeric, lcNumeric); + + QString result("Schweiz"); + QCOMPARE(locale.countryEndonym(), result); + + QBENCHMARK { + locale.countryEndonym(); + } +} + +QTEST_APPLESS_MAIN(Pt_MLocale); diff --git a/benchmarks/pt_mlocale/pt_mlocale.h b/benchmarks/pt_mlocale/pt_mlocale.h new file mode 100644 index 00000000..74849365 --- /dev/null +++ b/benchmarks/pt_mlocale/pt_mlocale.h @@ -0,0 +1,49 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libmeegotouch. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#ifndef PT_LOCALE_H +#define PT_LOCALE_H + +#include <QtTest/QtTest> +#include <QCoreApplication> +#include <QTextCodec> +#include <QObject> +#include <MLocale> +#ifdef HAVE_ICU +#include <unicode/uversion.h> +#endif + +class Pt_MLocale : public QObject +{ + Q_OBJECT + +private: + QCoreApplication *qap; + QString icuPackageVersion; + +private slots: + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); + + void benchmarkCountryEndonym(); +}; + +#endif diff --git a/benchmarks/pt_mlocale/pt_mlocale.pro b/benchmarks/pt_mlocale/pt_mlocale.pro new file mode 100644 index 00000000..ee165bfe --- /dev/null +++ b/benchmarks/pt_mlocale/pt_mlocale.pro @@ -0,0 +1,7 @@ +include(../common_top.pri) +INCLUDEPATH += $$MSRCDIR/include $$MSRCDIR/corelib/theme +DEPENDPATH += $$INCLUDEPATH +TARGET = pt_mlocale + +HEADERS += pt_mlocale.h +SOURCES += pt_mlocale.cpp |