diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-01-11 02:58:38 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-01-11 03:00:16 (GMT) |
commit | b6a7d7cc9c4eaab53213d0116e4f1d5cbd267004 (patch) | |
tree | 1c78a1208e27c9b31a2fb0a73dd7eedb73d6a196 /tests/benchmarks | |
parent | f4c5b030db674f9a76a0156d55c5140420c400dd (diff) | |
download | Qt-b6a7d7cc9c4eaab53213d0116e4f1d5cbd267004.zip Qt-b6a7d7cc9c4eaab53213d0116e4f1d5cbd267004.tar.gz Qt-b6a7d7cc9c4eaab53213d0116e4f1d5cbd267004.tar.bz2 |
More text benchmarks.
Diffstat (limited to 'tests/benchmarks')
-rw-r--r-- | tests/benchmarks/declarative/text/tst_text.cpp | 75 |
1 files changed, 73 insertions, 2 deletions
diff --git a/tests/benchmarks/declarative/text/tst_text.cpp b/tests/benchmarks/declarative/text/tst_text.cpp index e69ecd8..c7ea884 100644 --- a/tests/benchmarks/declarative/text/tst_text.cpp +++ b/tests/benchmarks/declarative/text/tst_text.cpp @@ -62,6 +62,11 @@ private slots: void document(); void paintDocToPixmap(); void paintDocToPixmap_painterFill(); + void control(); + void paintControlToPixmap(); + void paintControlToPixmap_painterFill(); + void constructControl(); + void constructDocument(); private: QString m_text; @@ -144,6 +149,48 @@ void tst_text::paintLayoutToPixmap_painterFill() void tst_text::document() { + QTextDocument *doc = new QTextDocument; + + QBENCHMARK { + QTextDocument *doc = new QTextDocument; + doc->setHtml(m_text); + } +} + +void tst_text::paintDocToPixmap() +{ + QTextDocument *doc = new QTextDocument; + doc->setHtml(m_text); + doc->setTextWidth(300); + QSize size = doc->size().toSize(); + + QBENCHMARK { + QPixmap img(size); + img.fill(Qt::transparent); + QPainter p(&img); + doc->drawContents(&p/*, QRectF(QPointF(0, 0), QSizeF(size))*/); + } +} + +void tst_text::paintDocToPixmap_painterFill() +{ + QTextDocument *doc = new QTextDocument; + doc->setHtml(m_text); + doc->setTextWidth(300); + QSize size = doc->size().toSize(); + + QBENCHMARK { + QPixmap img(size); + QPainter p(&img); + p.setCompositionMode(QPainter::CompositionMode_Source); + p.fillRect(0, 0, img.width(), img.height(), Qt::transparent); + p.setCompositionMode(QPainter::CompositionMode_SourceOver); + doc->drawContents(&p/*, QRectF(QPointF(0, 0), QSizeF(size))*/); + } +} + +void tst_text::control() +{ QTextControl *control = new QTextControl(m_text); QBENCHMARK { @@ -153,11 +200,12 @@ void tst_text::document() } } -void tst_text::paintDocToPixmap() +void tst_text::paintControlToPixmap() { QTextControl *control = new QTextControl; QTextDocument *doc = control->document(); doc->setHtml(m_text); + doc->setTextWidth(300); QSize size = doc->size().toSize(); QBENCHMARK { @@ -168,11 +216,12 @@ void tst_text::paintDocToPixmap() } } -void tst_text::paintDocToPixmap_painterFill() +void tst_text::paintControlToPixmap_painterFill() { QTextControl *control = new QTextControl; QTextDocument *doc = control->document(); doc->setHtml(m_text); + doc->setTextWidth(300); QSize size = doc->size().toSize(); QBENCHMARK { @@ -185,5 +234,27 @@ void tst_text::paintDocToPixmap_painterFill() } } +void tst_text::constructControl() +{ + QTextControl *control = new QTextControl; + delete control; + + QBENCHMARK { + QTextControl *control = new QTextControl; + delete control; + } +} + +void tst_text::constructDocument() +{ + QTextDocument *doc = new QTextDocument; + delete doc; + + QBENCHMARK { + QTextDocument *doc = new QTextDocument; + delete doc; + } +} + QTEST_MAIN(tst_text) #include "tst_text.moc" |