From 91bac7643928dcc1a0967abd30559b2c84b58025 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Tue, 8 May 2012 11:05:21 +1000 Subject: [PATCH] Text benchmarks Benchmarks to compare the cost of creating 42 text items in a grid vs. using a single text item with 42 lines and laying them out using onLineLaidOut. Change-Id: I4c11e23a3fd04bb8b52b5566fb120d336614c98b Reviewed-by: Michael Brasser --- tests/benchmarks/qml/qmltime/linelaidout.qml | 62 +++++++++++++++++++++++ tests/benchmarks/qml/qmltime/textingrid.qml | 73 ++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 tests/benchmarks/qml/qmltime/linelaidout.qml create mode 100644 tests/benchmarks/qml/qmltime/textingrid.qml diff --git a/tests/benchmarks/qml/qmltime/linelaidout.qml b/tests/benchmarks/qml/qmltime/linelaidout.qml new file mode 100644 index 0000000..d0e3560 --- /dev/null +++ b/tests/benchmarks/qml/qmltime/linelaidout.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Text { + width: 480 + height: width + text: "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42" + color: "blue" + font.pixelSize: 15 + font.bold: true + + onLineLaidOut: { + line.x = (line.number % 7) * 70 + line.y = Math.floor(line.number / 7.0) * 70 + } + } + } +} diff --git a/tests/benchmarks/qml/qmltime/textingrid.qml b/tests/benchmarks/qml/qmltime/textingrid.qml new file mode 100644 index 0000000..7c4de34 --- /dev/null +++ b/tests/benchmarks/qml/qmltime/textingrid.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Grid { + width: 480 + height: width + + id: grid + columns: 7 + rows: 6 + + Repeater { + model: 42 + Text { + width: grid.width / grid.columns; height: width + color: "blue" + text: index + font.pixelSize: 15 + font.bold: true + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + + } + } + + } + } +} + -- 2.7.4