52 }; |
51 }; |
53 |
52 |
54 /* |
53 /* |
55 Test the performance of the QApplication constructor. |
54 Test the performance of the QApplication constructor. |
56 |
55 |
57 This test creates a new process and thus includes process creation overhead. |
56 Note: results from the second start on can be misleading, |
58 Callgrind results are meaningless since the child process is not traced. |
57 since all global statics are already initialized. |
59 */ |
58 */ |
60 void tst_qapplication::ctor() |
59 void tst_qapplication::ctor() |
61 { |
60 { |
62 QProcess proc; |
61 // simulate reasonable argc, argv |
63 const QString program = QCoreApplication::applicationFilePath(); |
62 int argc = 1; |
64 const QStringList arguments = QStringList() << QLatin1String("--exit-now"); |
63 char *argv[] = { "tst_qapplication" }; |
65 |
|
66 QBENCHMARK { |
64 QBENCHMARK { |
67 proc.start(program, arguments); |
65 QApplication app(argc, argv); |
68 QVERIFY(proc.waitForStarted()); |
|
69 QVERIFY(proc.waitForFinished()); |
|
70 QCOMPARE(proc.exitStatus(), QProcess::NormalExit); |
|
71 QCOMPARE(proc.exitCode(), 0); |
|
72 } |
66 } |
73 } |
67 } |
74 |
68 |
75 int main(int argc, char** argv) |
69 QTEST_APPLESS_MAIN(tst_qapplication) |
76 { |
|
77 QApplication app(argc, argv); |
|
78 |
|
79 if (argc == 2 && QLatin1String("--exit-now") == QLatin1String(argv[1])) { |
|
80 return 0; |
|
81 } |
|
82 |
|
83 tst_qapplication test; |
|
84 return QTest::qExec(&test, argc, argv); |
|
85 } |
|
86 |
70 |
87 #include "main.moc" |
71 #include "main.moc" |