[clazy] [Bug 361691] Suggestion to turn string into QStringLiteral instead of QLatin1String
Sergio Martins via KDE Bugzilla
bugzilla_noreply at kde.org
Wed Apr 13 22:32:22 BST 2016
https://bugs.kde.org/show_bug.cgi?id=361691
--- Comment #5 from Sergio Martins <smartins at kde.org> ---
I don't have the original, but just wrote this:
#include <QString>
#include <QDebug>
#define N 100000000
bool testQStringLiteral()
{
qDebug() << "QStringLiteral";
bool result = false;
QString s;
for (int i = 0; i < N; ++i)
{
result |= s.contains(QStringLiteral("foo"));
}
return result;
}
bool testQLatin1String()
{
qDebug() << "QLatin1String";
bool result = false;
QString s;
for (int i = 0; i < N; ++i)
{
result |= s.contains(QLatin1String("foo"));
}
return result;
}
int main(int argv, char **)
{
if (argv == 1) {
return testQLatin1String();
} else {
return testQStringLiteral();
}
}
serj ~/lixo/st $ perf stat ./st 1
QStringLiteral
Performance counter stats for './st 1':
574.619866 task-clock (msec) # 0.999 CPUs utilized
2 context-switches # 0.003 K/sec
0 cpu-migrations # 0.000 K/sec
301 page-faults # 0.524 K/sec
1818862143 cycles # 3.165 GHz
<not supported> stalled-cycles-frontend
<not supported> stalled-cycles-backend
5707478658 instructions # 3.14 insns per cycle
1001376209 branches # 1742.676 M/sec
35138 branch-misses # 0.00% of all branches
0.575097370 seconds time elapsed
serj ~/lixo/st $ perf stat ./st
QLatin1String
Performance counter stats for './st':
1175.225780 task-clock (msec) # 1.000 CPUs utilized
2 context-switches # 0.002 K/sec
0 cpu-migrations # 0.000 K/sec
300 page-faults # 0.255 K/sec
3733101298 cycles # 3.176 GHz
<not supported> stalled-cycles-frontend
<not supported> stalled-cycles-backend
12508151290 instructions # 3.35 insns per cycle
2101498161 branches # 1788.165 M/sec
38406 branch-misses # 0.00% of all branches
1.175587617 seconds time elapsed
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the Unassigned-bugs
mailing list