public:
tst_qstringbuilder()
- : l1literal(LITERAL),
- l1string(LITERAL),
+ : l1string(LITERAL),
ba(LITERAL),
string(l1string),
stdstring(LITERAL),
return s;
}
- int run_builder()
- {
- int s = 0;
- for (int i = 0; i < N; ++i) {
-#if 0
- s += QString(l1literal P l1literal).size();
- s += QString(l1literal P l1literal P l1literal).size();
- s += QString(l1literal P l1literal P l1literal P l1literal).size();
- s += QString(l1literal P l1literal P l1literal P l1literal P l1literal).size();
-#endif
- s += QString(achar % l1literal % achar).size();
- }
- return s;
- }
-
private slots:
void separator_0() {
void separator_1() { SEP("literal + literal (builder first)"); }
- void b_2_l1literal() {
- QBENCHMARK { r = l1literal P l1literal; }
- COMPARE(r, r2);
- }
- #ifndef QT_NO_CAST_FROM_ASCII
- void b_l1literal_LITERAL() {
- QBENCHMARK { r = l1literal P LITERAL; }
- COMPARE(r, r2);
- }
- #endif
void q_2_l1string() {
QBENCHMARK { r = l1string + l1string; }
COMPARE(r, r2);
void separator_2a() { SEP("string + literal (builder first)"); }
- void b_string_l1literal() {
- QBENCHMARK { r = string % l1literal; }
- COMPARE(r, r2);
- }
#ifndef QT_NO_CAST_FROM_ASCII
void b_string_LITERAL() {
QBENCHMARK { r = string P LITERAL; }
QBENCHMARK { r = string P l1string; }
COMPARE(r, r2);
}
- void q_string_l1literal() {
- QBENCHMARK { r = string + l1string; }
- COMPARE(r, r2);
- }
void q_string_l1string() {
QBENCHMARK { r = string + l1string; }
COMPARE(r, r2);
void separator_3() { SEP("3 literals"); }
- void b_3_l1literal() {
- QBENCHMARK { r = l1literal P l1literal P l1literal; }
- COMPARE(r, r3);
- }
void q_3_l1string() {
QBENCHMARK { r = l1string + l1string + l1string; }
COMPARE(r, r3);
void separator_4() { SEP("4 literals"); }
- void b_4_l1literal() {
- QBENCHMARK { r = l1literal P l1literal P l1literal P l1literal; }
- COMPARE(r, r4);
- }
void q_4_l1string() {
QBENCHMARK { r = l1string + l1string + l1string + l1string; }
COMPARE(r, r4);
void separator_5() { SEP("5 literals"); }
- void b_5_l1literal() {
- QBENCHMARK { r = l1literal P l1literal P l1literal P l1literal P l1literal; }
- COMPARE(r, r5);
- }
-
void q_5_l1string() {
QBENCHMARK { r = l1string + l1string + l1string + l1string + l1string; }
COMPARE(r, r5);
void separator_8() { SEP("string.arg"); }
- void b_string_arg() {
- const QString pattern = l1string + QString::fromLatin1("%1") + l1string;
- QBENCHMARK { r = l1literal P string P l1literal; }
- COMPARE(r, r3);
- }
-
void q_string_arg() {
const QString pattern = l1string + QLatin1String("%1") + l1string;
QBENCHMARK { r = pattern.arg(string); }
}
COMPARE(r, r4);
}
- void b_reserve_lit() {
- QBENCHMARK {
- r.clear();
- r = string P l1literal P string P string;
- }
- COMPARE(r, r4);
- }
void s_reserve() {
QBENCHMARK {
r.clear();
}
private:
- const QLatin1Literal l1literal;
const QLatin1String l1string;
const QByteArray ba;
const QString string;