Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
kdevelop
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Christoph Roick
kdevelop
Commits
ec059fd9
Commit
ec059fd9
authored
Dec 04, 2020
by
Igor Kushnir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move benchmarks from test_indexedstring to bench_indexedstring
parent
3f7a8332
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
237 additions
and
151 deletions
+237
-151
kdevplatform/serialization/tests/CMakeLists.txt
kdevplatform/serialization/tests/CMakeLists.txt
+3
-0
kdevplatform/serialization/tests/bench_indexedstring.cpp
kdevplatform/serialization/tests/bench_indexedstring.cpp
+183
-0
kdevplatform/serialization/tests/bench_indexedstring.h
kdevplatform/serialization/tests/bench_indexedstring.h
+51
-0
kdevplatform/serialization/tests/test_indexedstring.cpp
kdevplatform/serialization/tests/test_indexedstring.cpp
+0
-141
kdevplatform/serialization/tests/test_indexedstring.h
kdevplatform/serialization/tests/test_indexedstring.h
+0
-10
No files found.
kdevplatform/serialization/tests/CMakeLists.txt
View file @
ec059fd9
...
...
@@ -9,7 +9,10 @@ remove_definitions(
if
(
BUILD_BENCHMARKS
)
ecm_add_test
(
bench_itemrepository.cpp LINK_LIBRARIES
LINK_LIBRARIES Qt5::Test KDev::Serialization KDev::Tests
)
ecm_add_test
(
bench_indexedstring.cpp LINK_LIBRARIES
LINK_LIBRARIES Qt5::Test KDev::Serialization KDev::Tests
)
set_tests_properties
(
bench_itemrepository PROPERTIES TIMEOUT 30
)
set_tests_properties
(
bench_indexedstring PROPERTIES TIMEOUT 30
)
endif
()
ecm_add_test
(
test_itemrepository.cpp
LINK_LIBRARIES Qt5::Test KDev::Serialization KDev::Tests
...
...
kdevplatform/serialization/tests/bench_indexedstring.cpp
0 → 100644
View file @
ec059fd9
/*
* This file is part of KDevelop
* Copyright 2012-2013 Milian Wolff <mail@milianw.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "bench_indexedstring.h"
#include <language/util/kdevhash.h>
#include <serialization/itemrepositoryregistry.h>
#include <serialization/indexedstring.h>
#include <QTest>
#include <QStandardPaths>
QTEST_GUILESS_MAIN
(
BenchIndexedString
)
using
namespace
KDevelop
;
void
BenchIndexedString
::
initTestCase
()
{
QStandardPaths
::
setTestModeEnabled
(
true
);
ItemRepositoryRegistry
::
initialize
(
m_repositoryPath
);
}
void
BenchIndexedString
::
cleanupTestCase
()
{
ItemRepositoryRegistry
::
deleteRepositoryFromDisk
(
m_repositoryPath
);
}
static
QVector
<
QString
>
generateData
()
{
QVector
<
QString
>
data
;
static
const
int
NUM_ITEMS
=
100000
;
data
.
resize
(
NUM_ITEMS
);
for
(
int
i
=
0
;
i
<
NUM_ITEMS
;
++
i
)
{
data
[
i
]
=
QStringLiteral
(
"/foo/%1"
).
arg
(
i
);
}
return
data
;
}
void
BenchIndexedString
::
bench_index
()
{
const
QVector
<
QString
>
data
=
generateData
();
QBENCHMARK
{
for
(
const
QString
&
item
:
data
)
{
IndexedString
idx
(
item
);
Q_UNUSED
(
idx
);
}
}
}
static
QVector
<
uint
>
setupTest
()
{
const
QVector
<
QString
>
data
=
generateData
();
QVector
<
uint
>
indices
;
indices
.
reserve
(
data
.
size
());
for
(
const
QString
&
item
:
data
)
{
IndexedString
idx
(
item
);
indices
<<
idx
.
index
();
}
return
indices
;
}
void
BenchIndexedString
::
bench_length
()
{
const
QVector
<
uint
>
indices
=
setupTest
();
QBENCHMARK
{
for
(
uint
index
:
indices
)
{
IndexedString
str
=
IndexedString
::
fromIndex
(
index
);
str
.
length
();
}
}
}
void
BenchIndexedString
::
bench_qstring
()
{
const
QVector
<
uint
>
indices
=
setupTest
();
QBENCHMARK
{
for
(
uint
index
:
indices
)
{
IndexedString
str
=
IndexedString
::
fromIndex
(
index
);
str
.
str
();
}
}
}
void
BenchIndexedString
::
bench_kurl
()
{
const
QVector
<
uint
>
indices
=
setupTest
();
QBENCHMARK
{
for
(
uint
index
:
indices
)
{
IndexedString
str
=
IndexedString
::
fromIndex
(
index
);
str
.
toUrl
();
}
}
}
void
BenchIndexedString
::
bench_qhashQString
()
{
const
QVector
<
QString
>
data
=
generateData
();
quint64
sum
=
0
;
QBENCHMARK
{
for
(
const
auto
&
string
:
data
)
{
sum
+=
qHash
(
string
);
}
}
QVERIFY
(
sum
>
0
);
}
void
BenchIndexedString
::
bench_qhashIndexedString
()
{
const
QVector
<
uint
>
indices
=
setupTest
();
quint64
sum
=
0
;
QBENCHMARK
{
for
(
uint
index
:
indices
)
{
sum
+=
qHash
(
IndexedString
::
fromIndex
(
index
));
}
}
QVERIFY
(
sum
>
0
);
}
void
BenchIndexedString
::
bench_hashString
()
{
const
QVector
<
QString
>
strings
=
generateData
();
QVector
<
QByteArray
>
byteArrays
;
byteArrays
.
reserve
(
strings
.
size
());
for
(
const
auto
&
string
:
strings
)
{
byteArrays
<<
string
.
toUtf8
();
}
quint64
sum
=
0
;
QBENCHMARK
{
for
(
const
auto
&
array
:
qAsConst
(
byteArrays
))
{
sum
+=
IndexedString
::
hashString
(
array
.
constData
(),
array
.
length
());
}
}
QVERIFY
(
sum
>
0
);
}
void
BenchIndexedString
::
bench_kdevhash
()
{
const
QVector
<
QString
>
strings
=
generateData
();
QVector
<
QByteArray
>
byteArrays
;
byteArrays
.
reserve
(
strings
.
size
());
for
(
const
auto
&
string
:
strings
)
{
byteArrays
<<
string
.
toUtf8
();
}
quint64
sum
=
0
;
QBENCHMARK
{
for
(
const
auto
&
array
:
qAsConst
(
byteArrays
))
{
sum
+=
KDevHash
()
<<
array
;
}
}
QVERIFY
(
sum
>
0
);
}
void
BenchIndexedString
::
bench_qSet
()
{
const
QVector
<
uint
>
indices
=
setupTest
();
QSet
<
IndexedString
>
set
;
QBENCHMARK
{
for
(
uint
index
:
indices
)
{
set
.
insert
(
IndexedString
::
fromIndex
(
index
));
}
}
}
kdevplatform/serialization/tests/bench_indexedstring.h
0 → 100644
View file @
ec059fd9
/*
* This file is part of KDevelop
* Copyright 2012-2013 Milian Wolff <mail@milianw.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BENCH_INDEXEDSTRING_H
#define BENCH_INDEXEDSTRING_H
#include <QDir>
#include <QObject>
class
BenchIndexedString
:
public
QObject
{
Q_OBJECT
private
Q_SLOTS
:
void
initTestCase
();
void
cleanupTestCase
();
void
bench_index
();
void
bench_length
();
void
bench_qstring
();
void
bench_kurl
();
void
bench_qhashQString
();
void
bench_qhashIndexedString
();
void
bench_hashString
();
void
bench_kdevhash
();
void
bench_qSet
();
private:
const
QString
m_repositoryPath
=
QDir
::
tempPath
()
+
QStringLiteral
(
"/bench_indexedstring"
);
};
#endif // BENCH_INDEXEDSTRING_H
kdevplatform/serialization/tests/test_indexedstring.cpp
View file @
ec059fd9
...
...
@@ -21,7 +21,6 @@
#include "test_indexedstring.h"
#include <language/util/kdevhash.h>
#include <serialization/itemrepositoryregistry.h>
#include <serialization/indexedstring.h>
#include <QTest>
...
...
@@ -70,146 +69,6 @@ void TestIndexedString::testUrl()
QTEST
(
indexed
.
str
(),
"string"
);
}
static
QVector
<
QString
>
generateData
()
{
QVector
<
QString
>
data
;
static
const
int
NUM_ITEMS
=
100000
;
data
.
resize
(
NUM_ITEMS
);
for
(
int
i
=
0
;
i
<
NUM_ITEMS
;
++
i
)
{
data
[
i
]
=
QStringLiteral
(
"/foo/%1"
).
arg
(
i
);
}
return
data
;
}
void
TestIndexedString
::
bench_index
()
{
const
QVector
<
QString
>
data
=
generateData
();
QBENCHMARK
{
for
(
const
QString
&
item
:
data
)
{
IndexedString
idx
(
item
);
Q_UNUSED
(
idx
);
}
}
}
static
QVector
<
uint
>
setupTest
()
{
const
QVector
<
QString
>
data
=
generateData
();
QVector
<
uint
>
indices
;
indices
.
reserve
(
data
.
size
());
for
(
const
QString
&
item
:
data
)
{
IndexedString
idx
(
item
);
indices
<<
idx
.
index
();
}
return
indices
;
}
void
TestIndexedString
::
bench_length
()
{
const
QVector
<
uint
>
indices
=
setupTest
();
QBENCHMARK
{
for
(
uint
index
:
indices
)
{
IndexedString
str
=
IndexedString
::
fromIndex
(
index
);
str
.
length
();
}
}
}
void
TestIndexedString
::
bench_qstring
()
{
const
QVector
<
uint
>
indices
=
setupTest
();
QBENCHMARK
{
for
(
uint
index
:
indices
)
{
IndexedString
str
=
IndexedString
::
fromIndex
(
index
);
str
.
str
();
}
}
}
void
TestIndexedString
::
bench_kurl
()
{
const
QVector
<
uint
>
indices
=
setupTest
();
QBENCHMARK
{
for
(
uint
index
:
indices
)
{
IndexedString
str
=
IndexedString
::
fromIndex
(
index
);
str
.
toUrl
();
}
}
}
void
TestIndexedString
::
bench_qhashQString
()
{
const
QVector
<
QString
>
data
=
generateData
();
quint64
sum
=
0
;
QBENCHMARK
{
for
(
const
auto
&
string
:
data
)
{
sum
+=
qHash
(
string
);
}
}
QVERIFY
(
sum
>
0
);
}
void
TestIndexedString
::
bench_qhashIndexedString
()
{
const
QVector
<
uint
>
indices
=
setupTest
();
quint64
sum
=
0
;
QBENCHMARK
{
for
(
uint
index
:
indices
)
{
sum
+=
qHash
(
IndexedString
::
fromIndex
(
index
));
}
}
QVERIFY
(
sum
>
0
);
}
void
TestIndexedString
::
bench_hashString
()
{
const
QVector
<
QString
>
strings
=
generateData
();
QVector
<
QByteArray
>
byteArrays
;
byteArrays
.
reserve
(
strings
.
size
());
for
(
const
auto
&
string
:
strings
)
{
byteArrays
<<
string
.
toUtf8
();
}
quint64
sum
=
0
;
QBENCHMARK
{
for
(
const
auto
&
array
:
qAsConst
(
byteArrays
))
{
sum
+=
IndexedString
::
hashString
(
array
.
constData
(),
array
.
length
());
}
}
QVERIFY
(
sum
>
0
);
}
void
TestIndexedString
::
bench_kdevhash
()
{
const
QVector
<
QString
>
strings
=
generateData
();
QVector
<
QByteArray
>
byteArrays
;
byteArrays
.
reserve
(
strings
.
size
());
for
(
const
auto
&
string
:
strings
)
{
byteArrays
<<
string
.
toUtf8
();
}
quint64
sum
=
0
;
QBENCHMARK
{
for
(
const
auto
&
array
:
qAsConst
(
byteArrays
))
{
sum
+=
KDevHash
()
<<
array
;
}
}
QVERIFY
(
sum
>
0
);
}
void
TestIndexedString
::
bench_qSet
()
{
const
QVector
<
uint
>
indices
=
setupTest
();
QSet
<
IndexedString
>
set
;
QBENCHMARK
{
for
(
uint
index
:
indices
)
{
set
.
insert
(
IndexedString
::
fromIndex
(
index
));
}
}
}
void
TestIndexedString
::
test
()
{
QFETCH
(
QString
,
data
);
...
...
kdevplatform/serialization/tests/test_indexedstring.h
View file @
ec059fd9
...
...
@@ -37,16 +37,6 @@ private Q_SLOTS:
void
testUrl_data
();
void
testUrl
();
void
bench_index
();
void
bench_length
();
void
bench_qstring
();
void
bench_kurl
();
void
bench_qhashQString
();
void
bench_qhashIndexedString
();
void
bench_hashString
();
void
bench_kdevhash
();
void
bench_qSet
();
void
test
();
void
test_data
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment