Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
5dd7780a
Commit
5dd7780a
authored
Jul 29, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try to stabilise descendantOfPropertyAccess performance test
Closes gh-22633
parent
77287f86
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
+16
-10
ConfigurationPropertySourcesTests.java
.../properties/source/ConfigurationPropertySourcesTests.java
+16
-10
No files found.
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesTests.java
View file @
5dd7780a
...
...
@@ -20,6 +20,7 @@ import java.util.Collections;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
java.util.function.Function
;
import
org.junit.jupiter.api.Disabled
;
import
org.junit.jupiter.api.Test
;
...
...
@@ -149,17 +150,22 @@ class ConfigurationPropertySourcesTests {
@Test
// gh-21416
void
descendantOfPropertyAccessWhenMutableWithCacheShouldBePerformant
()
{
StandardEnvironment
environment
=
createPerformanceTestEnvironment
(
true
);
Iterable
<
ConfigurationPropertySource
>
sources
=
ConfigurationPropertySources
.
get
(
environment
);
ConfigurationPropertyName
missing
=
ConfigurationPropertyName
.
of
(
"missing"
);
long
start
=
System
.
nanoTime
();
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
for
(
ConfigurationPropertySource
source
:
sources
)
{
assertThat
(
source
.
containsDescendantOf
(
missing
)).
isEqualTo
(
ConfigurationPropertyState
.
ABSENT
);
Function
<
StandardEnvironment
,
Long
>
descendantOfPerformance
=
(
environment
)
->
{
Iterable
<
ConfigurationPropertySource
>
sources
=
ConfigurationPropertySources
.
get
(
environment
);
ConfigurationPropertyName
missing
=
ConfigurationPropertyName
.
of
(
"missing"
);
long
start
=
System
.
nanoTime
();
for
(
int
i
=
0
;
i
<
1000
;
i
++)
{
for
(
ConfigurationPropertySource
source
:
sources
)
{
assertThat
(
source
.
containsDescendantOf
(
missing
)).
isEqualTo
(
ConfigurationPropertyState
.
ABSENT
);
}
}
}
long
total
=
TimeUnit
.
NANOSECONDS
.
toMillis
(
System
.
nanoTime
()
-
start
);
assertThat
(
total
).
isLessThan
(
1000
);
return
TimeUnit
.
NANOSECONDS
.
toMillis
(
System
.
nanoTime
()
-
start
);
};
StandardEnvironment
environment
=
createPerformanceTestEnvironment
(
false
);
long
baseline
=
descendantOfPerformance
.
apply
(
environment
);
ConfigurationPropertyCaching
.
get
(
environment
).
enable
();
long
cached
=
descendantOfPerformance
.
apply
(
environment
);
assertThat
(
cached
).
isLessThan
(
baseline
/
2
);
}
private
long
testPropertySourcePerformance
(
boolean
immutable
)
{
...
...
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