branches/work/~dfaure/testprogs/app_startup_benchmark
David Faure
faure at kde.org
Mon Oct 18 16:56:27 CEST 2010
SVN commit 1187179 by dfaure:
Some cleanups; write down the average results I get:
QProcess::startDetached 28 ms
KToolInvocation::startServiceByDesktopPath 20 ms
=> kdeinit is still useful these days.
With thanks to Kévin for this benchmark.
CCMAIL: kde-optimize at kde.org
M +17 -14 appstartupbenchmark.cpp
--- branches/work/~dfaure/testprogs/app_startup_benchmark/appstartupbenchmark.cpp #1187178:1187179
@@ -58,7 +58,7 @@
QDBusConnectionInterface *iface = QDBusConnection::sessionBus().interface();
if (iface->isServiceRegistered(m_service)) {
- kDebug() << "Stopping" << m_service;
+ //kDebug() << "Stopping" << m_service;
QEventLoop loop;
QDBusServiceWatcher watcher;
@@ -100,12 +100,8 @@
int result = t.elapsed();
- while (QDBusConnection::sessionBus().interface()->isServiceRegistered(m_service)) {
- kDebug() << "it's running, let's stop it...";
+ //kDebug() << "it's running, let's stop it...";
ensureServiceStopped();
- sleep(1);
- kDebug() << "done sleeping";
- }
Q_ASSERT(!QDBusConnection::sessionBus().interface()->isServiceRegistered(m_service));
@@ -115,7 +111,7 @@
private slots:
void delayedStartup()
{
- kDebug() << "Starting" << m_service << "using" << m_method;
+ //kDebug() << "Starting" << m_service << "using" << m_method;
switch(m_method) {
case QProcess: {
bool ok = QProcess::startDetached(m_program);
@@ -155,16 +151,15 @@
return results;
}
-double calculateAverage(const QList<int> results)
+static double calculateAverage(const QList<int>& results)
{
return std::accumulate(results.begin(), results.end(), 0.0) / results.size();
}
-double calculateVariance(const QList<int> results)
+static double calculateVariance(const QList<int>& results)
{
double avg = calculateAverage(results);
-
double result = 0;
foreach (int val, results) {
@@ -185,13 +180,21 @@
const QString service("org.kde.kuiserver");
const int iterations = 100;
- QList<int> processResults = executeBenchmark(program, service, StartupTimer::QProcess, iterations);
- kDebug() << "QProcess average:" << calculateAverage(processResults) << "(" << calculateVariance(processResults) << ")";
+ {
+ const QList<int> processResults = executeBenchmark(program, service, StartupTimer::QProcess, iterations);
+ kDebug() << "QProcess " << processResults;
+ kDebug() << "QProcess average:" << calculateAverage(processResults) << "( variance" << calculateVariance(processResults) << ")";
+ }
- QList<int> toolInvocationResults = executeBenchmark(program, service, StartupTimer::KToolInvocation, iterations);
- kDebug() << "KToolInvocation average:" << calculateAverage(toolInvocationResults) << "(" << calculateVariance(toolInvocationResults) << ")";
+ {
+ const QList<int> toolInvocationResults = executeBenchmark(program, service, StartupTimer::KToolInvocation, iterations);
+ kDebug() << "KToolInvocation" << toolInvocationResults;
+ kDebug() << "KToolInvocation average:" << calculateAverage(toolInvocationResults) << "( variance" << calculateVariance(toolInvocationResults) << ")";
+ }
return 0;
}
+// Averages on David's laptop: QProcess 28 ms, KToolInvocation 20 ms
+
#include "main.moc"
More information about the Kde-optimize
mailing list