diff options
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/castellano.txt | 18 | ||||
-rw-r--r-- | benchmark/chilean.txt | 50 | ||||
-rw-r--r-- | benchmark/main.cpp | 157 | ||||
-rw-r--r-- | benchmark/qstringlist.pro | 16 |
4 files changed, 241 insertions, 0 deletions
diff --git a/benchmark/castellano.txt b/benchmark/castellano.txt new file mode 100644 index 0000000..680da45 --- /dev/null +++ b/benchmark/castellano.txt @@ -0,0 +1,18 @@ +En un lugar de la Mancha, de cuyo nombre no quiero acordarme, no ha mucho +tiempo que vivía un hidalgo de los de lanza en astillero adarga antigua, rocín +flaco y galgo corredor. Una olla de algo más vaca que carnero, salpicón las +más noches, duelos y quebrantos los sábados, lantejas los viernes, algún +palomino de añadidura los domingos, consumían las tres partes de su hacienda. +El resto della concluían sayo de velarte, calzas de velludo para las fiestas, +con sus pantuflos de lo mesmo, y los días de entresemana se honraba con su +vellorí de lo más fino. + +Tenía en su casa una ama que pasaba de los cuarenta, y una sobrina que no +llegaba a los veinte, y un mozo de campo y plaza, que así ensillaba el rocín +como tomaba la podadera. Frisaba la edad de nuestro hidalgo con los cincuenta +años; era de complexión recia, seco de carnes, enjuto de rostro, gran +madrugador y amigo de la caza. Quieren decir que tenía el sobrenombre de +Quijada, o Quesada, que en esto hay alguna diferencia en los autores que deste +caso escriben; aunque, por conjeturas verosímiles, se deja entender que se +llamaba Quejana. Pero esto importa poco a nuestro cuento; basta que en la +narración dél no se salga un punto de la verdad. diff --git a/benchmark/chilean.txt b/benchmark/chilean.txt new file mode 100644 index 0000000..13cb2f4 --- /dev/null +++ b/benchmark/chilean.txt @@ -0,0 +1,50 @@ +POEMA 20 + +Puedo escribir los versos más tristes esta noche. + +Escribir, por ejemplo: «La noche está estrellada, +y tiritan, azules, los astros, a lo lejos». + +El viento de la noche gira en el cielo y canta. + +Puedo escribir los versos más tristes esta noche. +Yo la quise, y a veces ella también me quiso. + +En las noches como ésta la tuve entre mis brazos. +La besé tantas veces bajo el cielo infinito. + +Ella me quiso, a veces yo también la quería. +Cómo no haber amado sus grandes ojos fijos. + +Puedo escribir los versos más tristes esta noche. +Pensar que no la tengo. Sentir que la he perdido. + +Oír la noche inmensa, más inmensa sin ella. +Y el verso cae al alma como al pasto el rocío. + +Qué importa que mi amor no pudiera guardarla. +La noche está estrellada y ella no está conmigo. + +Eso es todo. A lo lejos alguien canta. A lo lejos. +Mi alma no se contenta con haberla perdido. + +Como para acercarla mi mirada la busca. +Mi corazón la busca, y ella no está conmigo. + +La misma noche que hace blanquear los mismos árboles. +Nosotros, los de entonces, ya no somos los mismos. + +Ya no la quiero, es cierto, pero cuánto la quise. +Mi voz buscaba el viento para tocar su oído. + +De otro. Será de otro. Como antes de mis besos. +Su voz, su cuerpo claro. Sus ojos infinitos. + +Ya no la quiero, es cierto, pero tal vez la quiero. +Es tan corto el amor, y es tan largo el olvido. + +Porque en noches como ésta la tuve entre mis brazos, +Mi alma no se contenta con haberla perdido. + +Aunque éste sea el último dolor que ella me causa, +y éstos sean los últimos versos que yo le escribo. diff --git a/benchmark/main.cpp b/benchmark/main.cpp new file mode 100644 index 0000000..3a05abb --- /dev/null +++ b/benchmark/main.cpp @@ -0,0 +1,157 @@ +/** This file is part of QtCollator ** + +Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* + +Contact: Nokia Corporation (info@qt.nokia.com)** + +GNU Lesser General Public License Usage +This file may be used 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. Please review the +following information to ensure the GNU Lesser General Public License version +2.1 requirements will be met: +http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + +In addition, as a special exception, Nokia gives you certain additional rights. +These rights are described in the Nokia Qt LGPL Exception version 1.1, included +in the file LGPL_EXCEPTION.txt in this package. + +GNU General Public License Usage +Alternatively, this file may be used under the terms of the GNU General Public +License version 3.0 as published by the Free Software Foundation and appearing +in the file LICENSE.GPL included in the packaging of this file. Please review +the following information to ensure the GNU General Public License version 3.0 +requirements will be met: http://www.gnu.org/copyleft/gpl.html. + +Other Usage +Alternatively, this file may be used in accordance with the terms and +conditions contained in a signed written agreement between you and Nokia. + +*/ + +#include <QtCore> +#include <QtTest> + +#include "qtcollator.h" + +class tst_QtCollator: public QObject +{ + Q_OBJECT + +private: + QStringList chileanData, chileanWords; + QStringList castellanoData, castellanoWords; + + QStringList allData, allWords; + + QStringList read(const QString &filename); + QStringList splitWords(const QStringList &list); + +public slots: + void initTestCase(); + void cleanupTestCase(); + +private slots: + void localeAwareCompare_data(); + void localeAwareCompare(); + + void normal_data(); + void normal(); +}; + +QStringList tst_QtCollator::splitWords(const QStringList &list) +{ + QStringList result; + foreach (const QString &s, list) + result << s.split(" "); + return result; +} + +QStringList tst_QtCollator::read(const QString &filename) +{ + QFile file(filename); + if (!file.open(QFile::ReadOnly)) + return QStringList(); + + QByteArray data = file.readAll(); + return QString::fromUtf8(data.constData(), data.size()).split("\n"); +} + +void tst_QtCollator::initTestCase() +{ + chileanData = read("chilean.txt"); + chileanWords = splitWords(chileanData); + castellanoData = read("castellano.txt"); + castellanoWords = splitWords(castellanoData); + + allData << chileanData << castellanoData; + allWords << chileanWords << castellanoWords; +} + +void tst_QtCollator::cleanupTestCase() +{ + +} + +void tst_QtCollator::localeAwareCompare_data() +{ + normal_data(); +} + +void tst_QtCollator::normal_data() +{ + QTest::addColumn<QString>("locale"); + QTest::addColumn<QStringList>("data"); + + QTest::newRow("pt-PT:chilean:data") << "pt-PT" << chileanData; + QTest::newRow("pt-PT:chilean:words") << "pt-PT" << chileanWords; + QTest::newRow("pt-PT:castellano:data") << "pt-PT" << castellanoData; + QTest::newRow("pt-PT:castellano:words") << "pt-PT" << castellanoWords; + + QTest::newRow("pt-PT:all:data") << "pt-PT" << allData; + QTest::newRow("pt-PT:all:words") << "pt-PT" << allWords; + + QTest::newRow("zh-CN:all:data") << "zh-CN" << allData; + QTest::newRow("zh-CN:all:words") << "zh-CN" << allWords; + + QTest::newRow("fr-FR:all:data") << "fr-FR" << allData; + QTest::newRow("fr-FR:all:words") << "fr-FR" << allWords; + + QTest::newRow("fr-CA:all:data") << "fr-CA" << allData; + QTest::newRow("fr-Ca:all:words") << "fr-CA" << allWords; +} + +void tst_QtCollator::normal() +{ + QFETCH(QString, locale); + QFETCH(QStringList, data); + + QtCollator collator(locale); + + QBENCHMARK { + qSort(data.begin(), data.end(), collator); + } +} + +struct Comparator +{ + inline bool operator()(const QString &s1, const QString &s2) const + { return s1.localeAwareCompare(s2) < 0; } +}; + +void tst_QtCollator::localeAwareCompare() +{ + QFETCH(QString, locale); + QFETCH(QStringList, data); + + Comparator c; + + QBENCHMARK { + qSort(data.begin(), data.end(), c); + } +} + + +QTEST_MAIN(tst_QtCollator) + +#include "main.moc" diff --git a/benchmark/qstringlist.pro b/benchmark/qstringlist.pro new file mode 100644 index 0000000..e43cb37 --- /dev/null +++ b/benchmark/qstringlist.pro @@ -0,0 +1,16 @@ +TARGET = tst_bench_qtcollator +CONFIG -= debug +CONFIG += release +QT -= gui +QT += testlib + +INCLUDEPATH += . .. +win32:INCLUDEPATH += . .. c:/users/denis/dev/icu/include + +unix:LIBS += -licuuc -licui18n +win32:LIBS += -Lc:/users/denis/dev/icu/lib -licuin + +# Input +HEADERS += ../qtcollator.h +SOURCES += main.cpp ../qtcollator.cpp + |