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
62a3f823
Commit
62a3f823
authored
Dec 01, 2020
by
Igor Kushnir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add benchmarks sensitive to DUChainReferenceCounting's performance
parent
ec059fd9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
109 additions
and
0 deletions
+109
-0
kdevplatform/serialization/tests/bench_indexedstring.cpp
kdevplatform/serialization/tests/bench_indexedstring.cpp
+61
-0
kdevplatform/serialization/tests/bench_indexedstring.h
kdevplatform/serialization/tests/bench_indexedstring.h
+3
-0
kdevplatform/serialization/tests/bench_itemrepository.cpp
kdevplatform/serialization/tests/bench_itemrepository.cpp
+42
-0
kdevplatform/serialization/tests/bench_itemrepository.h
kdevplatform/serialization/tests/bench_itemrepository.h
+3
-0
No files found.
kdevplatform/serialization/tests/bench_indexedstring.cpp
View file @
62a3f823
/*
* This file is part of KDevelop
* Copyright 2012-2013 Milian Wolff <mail@milianw.de>
* Copyright 2020 Igor Kushnir <igorkuo@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
...
...
@@ -24,9 +25,13 @@
#include <language/util/kdevhash.h>
#include <serialization/itemrepositoryregistry.h>
#include <serialization/indexedstring.h>
#include <tests/testhelpers.h>
#include <QTest>
#include <QStandardPaths>
#include <vector>
QTEST_GUILESS_MAIN
(
BenchIndexedString
)
using
namespace
KDevelop
;
...
...
@@ -181,3 +186,59 @@ void BenchIndexedString::bench_qSet()
}
}
}
static
std
::
vector
<
IndexedString
>
createIndexedStrings
(
std
::
size_t
count
)
{
std
::
vector
<
IndexedString
>
result
;
// result.reserve(count) is called after verifying that count is not too great.
constexpr
char
first
{
33
};
constexpr
char
last
{
127
};
constexpr
std
::
size_t
dataSize
{
4
};
std
::
size_t
maxCount
{
1
};
for
(
std
::
size_t
i
=
0
;
i
<
dataSize
;
++
i
)
{
maxCount
*=
(
last
-
first
);
}
// Subtract 1 to account for the fact that count is checked at the beginning
// of the innermost loop in order to support count == 0.
--
maxCount
;
QVERIFY_RETURN
(
count
<=
maxCount
,
result
);
result
.
reserve
(
count
);
char
data
[
dataSize
+
1
]
=
{};
QCOMPARE_RETURN
(
data
[
dataSize
],
0
,
result
);
for
(
char
a
=
first
;
a
!=
last
;
++
a
)
{
data
[
0
]
=
a
;
for
(
char
b
=
first
;
b
!=
last
;
++
b
)
{
data
[
1
]
=
b
;
for
(
char
c
=
first
;
c
!=
last
;
++
c
)
{
data
[
2
]
=
c
;
for
(
char
d
=
first
;
d
!=
last
;
++
d
)
{
if
(
count
--
==
0
)
{
return
result
;
}
data
[
3
]
=
d
;
result
.
emplace_back
(
data
,
dataSize
);
}
}
}
}
Q_UNREACHABLE
();
}
void
BenchIndexedString
::
bench_create
()
{
QBENCHMARK_ONCE
{
createIndexedStrings
(
1'000'000
);
}
}
void
BenchIndexedString
::
bench_destroy
()
{
auto
strings
=
createIndexedStrings
(
10'000'000
);
QBENCHMARK_ONCE
{
strings
=
{};
}
}
kdevplatform/serialization/tests/bench_indexedstring.h
View file @
62a3f823
...
...
@@ -44,6 +44,9 @@ private Q_SLOTS:
void
bench_kdevhash
();
void
bench_qSet
();
void
bench_create
();
void
bench_destroy
();
private:
const
QString
m_repositoryPath
=
QDir
::
tempPath
()
+
QStringLiteral
(
"/bench_indexedstring"
);
};
...
...
kdevplatform/serialization/tests/bench_itemrepository.cpp
View file @
62a3f823
...
...
@@ -23,9 +23,12 @@
#include <serialization/itemrepository.h>
#include <serialization/indexedstring.h>
#include <serialization/referencecounting.h>
#include <algorithm>
#include <limits>
#include <random>
#include <vector>
#include <QTest>
#include <QStandardPaths>
...
...
@@ -227,3 +230,42 @@ void BenchItemRepository::lookupValue()
}
}
}
void
BenchItemRepository
::
shouldDoReferenceCounting_data
()
{
QTest
::
addColumn
<
bool
>
(
"enableReferenceCounting"
);
QTest
::
newRow
(
"disabled"
)
<<
false
;
QTest
::
newRow
(
"enabled"
)
<<
true
;
}
void
BenchItemRepository
::
shouldDoReferenceCounting
()
{
using
Type
=
unsigned
;
static_assert
(
sizeof
(
Type
)
==
sizeof
(
IndexedString
),
"Type emulates inlined IndexedString and should be of the same size."
);
constexpr
std
::
size_t
valueCount
{
100'000'000
};
std
::
vector
<
Type
>
values
(
valueCount
);
QFETCH
(
bool
,
enableReferenceCounting
);
if
(
enableReferenceCounting
)
{
enableDUChainReferenceCounting
(
&
values
.
front
(),
values
.
size
()
*
sizeof
(
Type
));
}
// NOTE: switching CountType from int to std::size_t slows down the "disabled" benchmark
// by 17% and the "enabled" benchmark by 5%, as does removing the static_cast<CountType> below!
using
CountType
=
int
;
CountType
count
{
0
};
static_assert
(
valueCount
<=
std
::
numeric_limits
<
CountType
>::
max
());
QBENCHMARK_ONCE
{
for
(
auto
&
v
:
values
)
{
count
+=
shouldDoDUChainReferenceCounting
(
&
v
);
}
}
if
(
enableReferenceCounting
)
{
disableDUChainReferenceCounting
(
&
values
.
front
());
QCOMPARE
(
count
,
static_cast
<
CountType
>
(
values
.
size
()));
}
else
{
QCOMPARE
(
count
,
0
);
}
}
kdevplatform/serialization/tests/bench_itemrepository.h
View file @
62a3f823
...
...
@@ -40,6 +40,9 @@ private Q_SLOTS:
void
lookupKey
();
void
lookupValue
();
void
shouldDoReferenceCounting_data
();
void
shouldDoReferenceCounting
();
private:
const
QString
m_repositoryPath
=
QDir
::
tempPath
()
+
QStringLiteral
(
"/bench_itemrepository"
);
};
...
...
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