diff options
Diffstat (limited to 'tests/benchmarks')
-rw-r--r-- | tests/benchmarks/corelib/tools/qlocale/main.cpp | 83 | ||||
-rw-r--r-- | tests/benchmarks/corelib/tools/qlocale/qlocale.pro | 5 | ||||
-rw-r--r-- | tests/benchmarks/corelib/tools/tools.pro | 1 | ||||
-rw-r--r-- | tests/benchmarks/sql/kernel/qsqlquery/main.cpp | 32 |
4 files changed, 106 insertions, 15 deletions
diff --git a/tests/benchmarks/corelib/tools/qlocale/main.cpp b/tests/benchmarks/corelib/tools/qlocale/main.cpp new file mode 100644 index 0000000000..c62baf556e --- /dev/null +++ b/tests/benchmarks/corelib/tools/qlocale/main.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QLocale> +#include <QTest> + +class tst_QLocale : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void toUpper_QLocale_1(); + void toUpper_QLocale_2(); + void toUpper_QString(); +}; + +static QString data() +{ + return QStringLiteral("/qt-5/qtbase/tests/benchmarks/corelib/tools/qlocale"); +} + +#define LOOP(s) for (int i = 0; i < 5000; ++i) { s; } + +void tst_QLocale::toUpper_QLocale_1() +{ + QString s = data(); + QBENCHMARK { LOOP(QLocale().toUpper(s)) } +} + +void tst_QLocale::toUpper_QLocale_2() +{ + QString s = data(); + QLocale l; + QBENCHMARK { LOOP(l.toUpper(s)) } +} + +void tst_QLocale::toUpper_QString() +{ + QString s = data(); + QBENCHMARK { LOOP(s.toUpper()) } +} + +QTEST_MAIN(tst_QLocale) + +#include "main.moc" diff --git a/tests/benchmarks/corelib/tools/qlocale/qlocale.pro b/tests/benchmarks/corelib/tools/qlocale/qlocale.pro new file mode 100644 index 0000000000..9e8f2721c9 --- /dev/null +++ b/tests/benchmarks/corelib/tools/qlocale/qlocale.pro @@ -0,0 +1,5 @@ +TARGET = tst_bench_qlocale +QT = core testlib + +SOURCES += main.cpp +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/benchmarks/corelib/tools/tools.pro b/tests/benchmarks/corelib/tools/tools.pro index 7565b1a167..ce3e75acd7 100644 --- a/tests/benchmarks/corelib/tools/tools.pro +++ b/tests/benchmarks/corelib/tools/tools.pro @@ -5,6 +5,7 @@ SUBDIRS = \ qbytearray \ qcontiguouscache \ qlist \ + qlocale \ qmap \ qrect \ qregexp \ diff --git a/tests/benchmarks/sql/kernel/qsqlquery/main.cpp b/tests/benchmarks/sql/kernel/qsqlquery/main.cpp index 2bce545f90..4e6a444366 100644 --- a/tests/benchmarks/sql/kernel/qsqlquery/main.cpp +++ b/tests/benchmarks/sql/kernel/qsqlquery/main.cpp @@ -117,6 +117,7 @@ void tst_QSqlQuery::cleanup() QFETCH( QString, dbName ); QSqlDatabase db = QSqlDatabase::database( dbName ); CHECK_DATABASE( db ); + const QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); if ( QTest::currentTestFunction() == QLatin1String( "numRowsAffected" ) || QTest::currentTestFunction() == QLatin1String( "transactions" ) @@ -126,8 +127,7 @@ void tst_QSqlQuery::cleanup() populateTestTables( db ); } - if ( QTest::currentTestFailed() && ( db.driverName().startsWith( "QOCI" ) - || db.driverName().startsWith( "QODBC" ) ) ) { + if (QTest::currentTestFailed() && (dbType == QSqlDriverPrivate::Oracle || db.driverName().startsWith("QODBC"))) { //since Oracle ODBC totally craps out on error, we init again db.close(); db.open(); @@ -146,6 +146,7 @@ void tst_QSqlQuery::generic_data(const QString& engine) void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) { + QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); QStringList tablenames; // drop all the table in case a testcase failed tablenames << qtest @@ -179,24 +180,24 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) << qTableName("test141895", __FILE__, db) << qTableName("qtest_oraOCINumber", __FILE__, db); - if ( db.driverName().startsWith("QPSQL") ) + if (dbType == QSqlDriverPrivate::PostgreSQL) tablenames << qTableName("task_233829", __FILE__, db); - if ( db.driverName().startsWith("QSQLITE") ) + if (dbType == QSqlDriverPrivate::SQLite) tablenames << qTableName("record_sqlite", __FILE__, db); - if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QOCI" ) ) + if (dbType == QSqlDriverPrivate::MSSqlServer || dbType == QSqlDriverPrivate::Oracle) tablenames << qTableName("qtest_longstr", __FILE__, db); - if (tst_Databases::isSqlServer( db )) + if (dbType == QSqlDriverPrivate::MSSqlServer) db.exec("DROP PROCEDURE " + qTableName("test141895_proc", __FILE__, db)); - if (tst_Databases::isMySQL( db )) + if (dbType == QSqlDriverPrivate::MySqlServer) db.exec("DROP PROCEDURE IF EXISTS "+qTableName("bug6852_proc", __FILE__, db)); tst_Databases::safeDropTables( db, tablenames ); - if ( db.driverName().startsWith( "QOCI" ) ) { + if (dbType == QSqlDriverPrivate::Oracle) { QSqlQuery q( db ); q.exec("DROP PACKAGE " + qTableName("pkg", __FILE__, db)); } @@ -204,24 +205,25 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) void tst_QSqlQuery::createTestTables( QSqlDatabase db ) { + const QString qtestNull = qTableName("qtest_null", __FILE__, db); QSqlQuery q( db ); - - if ( db.driverName().startsWith( "QMYSQL" ) ) + QSqlDriverPrivate::DBMSType dbType = tst_Databases::getDatabaseType(db); + if (dbType == QSqlDriverPrivate::MySqlServer) // ### stupid workaround until we find a way to hardcode this // in the MySQL server startup script q.exec( "set table_type=innodb" ); - else if (tst_Databases::isPostgreSQL(db)) + else if (dbType == QSqlDriverPrivate::PostgreSQL) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); - if (tst_Databases::isPostgreSQL(db)) + if (dbType == QSqlDriverPrivate::PostgreSQL) QVERIFY_SQL( q, exec( "create table " + qtest + " (id serial NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id)) WITH OIDS" ) ); else QVERIFY_SQL( q, exec( "create table " + qtest + " (id int "+tst_Databases::autoFieldName(db) +" NOT NULL, t_varchar varchar(20), t_char char(20), primary key(id))" ) ); - if ( tst_Databases::isSqlServer( db ) || db.driverName().startsWith( "QTDS" ) ) - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_null", __FILE__, db) + " (id int null, t_varchar varchar(20) null)" ) ); + if (dbType == QSqlDriverPrivate::MSSqlServer || dbType == QSqlDriverPrivate::Sybase) + QVERIFY_SQL(q, exec("create table " + qtestNull + " (id int null, t_varchar varchar(20) null)")); else - QVERIFY_SQL(q, exec("create table " + qTableName("qtest_null", __FILE__, db) + " (id int, t_varchar varchar(20))" ) ); + QVERIFY_SQL(q, exec("create table " + qtestNull + " (id int, t_varchar varchar(20))")); } void tst_QSqlQuery::populateTestTables( QSqlDatabase db ) |