Skip to content
Commit ad1bd190 authored by Alexander Lohnau's avatar Alexander Lohnau
Browse files

Optimize services runner

By reusing the QList of KService::Ptr we get significantly better performance.

I used the following simple testcase for a real-world usage:
```cpp
    void benchmark()
    {
        QBENCHMARK {
            ServiceRunner runner(this, KPluginMetaData(), QVariantList());
            runner.prepare();
            for (int i = 0; i < 5; ++i) {
                Plasma::RunnerContext context;
                context.setQuery(QStringLiteral("firefox").left(i + 1)); // virt-manager.desktop
                runner.match(context);
            }
            runner.teardown();
        }
    }
```

Before, the test used ~150ms for each iteration. With this change it is down to ~76ms.
We do not block the main ui, because this is done in a separate thread, but this is still a significant
performance improvement. Especially considering that this runner is pretty much always used by the other
KDE launchers and even Plasma Mobile.

A further optimization would be to initialize the data once for each match session and reuse if for consequent queries.
However, benchmarks indicated relatively little gain and it would add extra complexity.
parent b9eed3ce
Pipeline #234195 passed with stage
in 8 minutes and 42 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment