Warning, file /kdevelop/kdev-php/duchain/tests/benchmarks.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2009 Milian Wolff <mail@milianw.de> 0003 0004 SPDX-License-Identifier: LGPL-2.0-only 0005 */ 0006 0007 #include "benchmarks.h" 0008 0009 #include <QtTest> 0010 #include <QFile> 0011 0012 #include <language/duchain/duchain.h> 0013 #include <language/duchain/duchainlock.h> 0014 0015 #include "../../parser/parsesession.h" 0016 0017 #include "../builders/declarationbuilder.h" 0018 #include "../builders/usebuilder.h" 0019 0020 using namespace KDevelop; 0021 0022 QTEST_MAIN(Php::Benchmarks) 0023 0024 namespace Php 0025 { 0026 0027 Benchmarks::Benchmarks() 0028 { 0029 } 0030 0031 QIODevice* getInternalFile() 0032 { 0033 QIODevice* file = new QFile(internalFunctionFile().str()); 0034 bool opened = file->open(QIODevice::ReadOnly); 0035 Q_ASSERT(opened); 0036 Q_UNUSED(opened); 0037 return file; 0038 } 0039 0040 void Benchmarks::parser() 0041 { 0042 QIODevice* file = getInternalFile(); 0043 QBENCHMARK { 0044 ParseSession session = ParseSession(); 0045 session.setContents(file->readAll()); 0046 StartAst* ast = nullptr; 0047 session.parse(&ast); 0048 } 0049 delete file; 0050 } 0051 0052 void Benchmarks::declarationBuilder() 0053 { 0054 QIODevice* file = getInternalFile(); 0055 ParseSession session; 0056 session.setContents(file->readAll()); 0057 delete file; 0058 StartAst* ast = nullptr; 0059 session.parse(&ast); 0060 EditorIntegrator editor(&session); 0061 QBENCHMARK { 0062 DeclarationBuilder builder(&editor); 0063 builder.build(internalFunctionFile(), ast); 0064 } 0065 } 0066 0067 void Benchmarks::useBuilder() 0068 { 0069 const auto document = IndexedString(QUrl(QStringLiteral("file:///internal/BigTestFile.php"))); 0070 0071 QIODevice* file = getInternalFile(); 0072 ParseSession session = ParseSession(); 0073 session.setCurrentDocument(document); 0074 session.setContents(file->readAll()); 0075 delete file; 0076 0077 StartAst* ast = nullptr; 0078 session.parse(&ast); 0079 EditorIntegrator editor(&session); 0080 DeclarationBuilder builder(&editor); 0081 0082 KDevelop::ReferencedTopDUContext chain = builder.build(document, ast); 0083 QBENCHMARK { 0084 UseBuilder useBuilder(&editor); 0085 useBuilder.buildUses(ast); 0086 } 0087 } 0088 0089 } 0090 0091 #include "moc_benchmarks.cpp"