<table><tr><td style="">ahmadsamir added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D26366">View Revision</a></tr></table><br /><div><div><p>I hacked up some (rather crude, to say the least) benchmarking:</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">void KLocalizedStringTest::benchmarkRegexSimple()
{
    QString roleName, cueName, formatName;
    QString context = QStringLiteral("@info:tooltip/plaintext");

    QBENCHMARK {
        if (context.startsWith(QLatin1Char('@'))) { // found UI marker
            static QRegularExpression wsRx(QStringLiteral("\\s"));
            context = context.mid(1, wsRx.match(context).capturedStart(0) - 1);

            // Possible format.
            int pfmt = context.indexOf(QLatin1Char('/'));
            if (pfmt >= 0) {
                formatName = context.mid(pfmt + 1);
                context.truncate(pfmt);
            }

            // Possible subcue.
            int pcue = context.indexOf(QLatin1Char(':'));
            if (pcue >= 0) {
                cueName = context.mid(pcue + 1);
                context.truncate(pcue);
            }

            // Role.
            roleName = context;
        }
    }
}

void KLocalizedStringTest::benchmarkRegex2()
{
    QString roleName, cueName, formatName;
    QString context = QStringLiteral("@info:tooltip/plaintext");

    QBENCHMARK {
        static const QRegularExpression rolesRx(QStringLiteral("^@(\\w+):?(\\w*)/?(\\w*)"));
        const QRegularExpressionMatch match = rolesRx.match(context);
        if (match.hasMatch()) {
            roleName = match.captured(1);
            cueName = match.captured(2);
            formatName = match.captured(3);
        }
    }
}</pre></div>

<p>and the results were:</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">PASS   : KLocalizedStringTest::benchmarkRegexSimple()
RESULT : KLocalizedStringTest::benchmarkRegexSimple():
     0.0000098 msecs per iteration (total: 83, iterations: 8388608)
PASS   : KLocalizedStringTest::benchmarkRegex2()
RESULT : KLocalizedStringTest::benchmarkRegex2():
     0.00054 msecs per iteration (total: 72, iterations: 131072)</pre></div>

<p>it doesn't look like a lot of difference to me; WDYT?</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R249 KI18n</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D26366">https://phabricator.kde.org/D26366</a></div></div><br /><div><strong>To: </strong>ahmadsamir, Frameworks, ilic, dfaure, mlaurent, aacid<br /><strong>Cc: </strong>kde-frameworks-devel, LeGast00n, GB_2, michaelh, ngraham, bruns<br /></div>