Skip to content

Commit fa0a781

Browse files
committed
Benchmark for single threaded case of parsing ZonedDateTime from timestamp string
Benchmark is build with JMH. UnitTests for verifying logic are provided. Sample results from my machine are attached.
0 parents  commit fa0a781

File tree

10 files changed

+585
-0
lines changed

10 files changed

+585
-0
lines changed

.gitignore

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### JetBrains template
3+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
4+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
5+
6+
# User-specific stuff:
7+
.idea/tasks.xml
8+
.idea/dictionaries
9+
.idea/jsLibraryMappings.xml
10+
11+
# Sensitive or high-churn files:
12+
.idea/dataSources.ids
13+
.idea/dataSources.xml
14+
.idea/dataSources.local.xml
15+
.idea/sqlDataSources.xml
16+
.idea/dynamic.xml
17+
.idea/uiDesigner.xml
18+
19+
# Mongo Explorer plugin:
20+
.idea/mongoSettings.xml
21+
22+
## File-based project format:
23+
*.iws
24+
25+
## Plugin-specific files:
26+
27+
# IntelliJ
28+
/out/
29+
30+
# mpeltonen/sbt-idea plugin
31+
.idea_modules/
32+
33+
# JIRA plugin
34+
atlassian-ide-plugin.xml
35+
36+
# Crashlytics plugin (for Android Studio and IntelliJ)
37+
com_crashlytics_export_strings.xml
38+
crashlytics.properties
39+
crashlytics-build.properties
40+
fabric.properties
41+
### Windows template
42+
# Windows image file caches
43+
Thumbs.db
44+
ehthumbs.db
45+
46+
# Folder config file
47+
Desktop.ini
48+
49+
# Recycle Bin used on file shares
50+
$RECYCLE.BIN/
51+
52+
# Windows Installer files
53+
*.cab
54+
*.msi
55+
*.msm
56+
*.msp
57+
58+
# Windows shortcuts
59+
*.lnk
60+
### Example user template template
61+
### Example user template
62+
63+
# IntelliJ project files
64+
.idea
65+
*.iml
66+
out
67+
gen### Java template
68+
*.class
69+
70+
# Mobile Tools for Java (J2ME)
71+
.mtj.tmp/
72+
73+
# Package Files #
74+
*.jar
75+
*.war
76+
*.ear
77+
78+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
79+
hs_err_pid*
80+

README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# DateTimeFormatBenchmarks
2+
3+
JMH based benchmarks to evaluate parsing a timestamp (with zone) to a ZonedDateTime (single threaded case)
4+
5+
## Participants:
6+
* java.time.ZonedDateTime#parse with java.time.format.DateTimeFormatter
7+
* org.apache.commons.lang3.time.FastDateFormat (with conversion)
8+
* org.joda.time.format.DateTimeFormat (with conversion)
9+
10+
## To build & run
11+
`gradlew jmh`
12+
13+
## Results
14+
15+
| Benchmark | Mode | Cnt | Score | Error | Units |
16+
| ---- | ----- | --- | ---------: | ---------: | ----- |
17+
| ZonedDateTimeBenchmark.zonedDateTimeParse | thrpt | 200 | 98270,686 | ± 407,439 | ops/s |
18+
| ZonedDateTimeBenchmark.fastDateFormat | thrpt | 200 | 594823,336 | ± 3296,509 | ops/s |
19+
| ZonedDateTimeBenchmark.jodaDateTimeFormatter | thrpt | 200 | 728459,747 | ± 5566,384 | ops/s |
20+
21+
## Info
22+
* Intel Core i7 3632QM
23+
* JMH 1.11.3
24+
* JDK 1.8.0_11, VM 25.11-b03
25+
* Warmup: 20 iterations, 1 s each
26+
* Measurement: 20 iterations, 1 s each
27+
* Timeout: 10 min per iteration
28+
* Threads: 1 thread, will synchronize iterations
29+
* Benchmark mode: Throughput, ops/time

benchDateTimeFormat.ipr

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project version="4">
3+
<component name="CompilerConfiguration">
4+
<option name="DEFAULT_COMPILER" value="Javac"/>
5+
<resourceExtensions>
6+
<entry name=".+\.(properties|xml|html|dtd|tld)"/>
7+
<entry name=".+\.(gif|png|jpeg|jpg)"/>
8+
</resourceExtensions>
9+
<wildcardResourcePatterns>
10+
<entry name="!?*.java"/>
11+
<entry name="!?*.groovy"/>
12+
</wildcardResourcePatterns>
13+
<annotationProcessing enabled="false" useClasspath="true"/>
14+
</component>
15+
<component name="CopyrightManager" default="">
16+
<module2copyright/>
17+
</component>
18+
<component name="DependencyValidationManager">
19+
<option name="SKIP_IMPORT_STATEMENTS" value="false"/>
20+
</component>
21+
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false"/>
22+
<component name="GradleUISettings">
23+
<setting name="root"/>
24+
</component>
25+
<component name="GradleUISettings2">
26+
<setting name="root"/>
27+
</component>
28+
<component name="IdProvider" IDEtalkID="11DA1DB66DD62DDA1ED602B7079FE97C"/>
29+
<component name="JavadocGenerationManager">
30+
<option name="OUTPUT_DIRECTORY"/>
31+
<option name="OPTION_SCOPE" value="protected"/>
32+
<option name="OPTION_HIERARCHY" value="true"/>
33+
<option name="OPTION_NAVIGATOR" value="true"/>
34+
<option name="OPTION_INDEX" value="true"/>
35+
<option name="OPTION_SEPARATE_INDEX" value="true"/>
36+
<option name="OPTION_DOCUMENT_TAG_USE" value="false"/>
37+
<option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false"/>
38+
<option name="OPTION_DOCUMENT_TAG_VERSION" value="false"/>
39+
<option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true"/>
40+
<option name="OPTION_DEPRECATED_LIST" value="true"/>
41+
<option name="OTHER_OPTIONS" value=""/>
42+
<option name="HEAP_SIZE"/>
43+
<option name="LOCALE"/>
44+
<option name="OPEN_IN_BROWSER" value="true"/>
45+
</component>
46+
<component name="ProjectModuleManager">
47+
<modules>
48+
<module fileurl="file://$PROJECT_DIR$/benchDateTimeFormat.iml" filepath="$PROJECT_DIR$/benchDateTimeFormat.iml"/>
49+
</modules>
50+
</component>
51+
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="true" jdk-15="true" project-jdk-type="JavaSDK" assert-jdk-15="true" project-jdk-name="1.8">
52+
<output url="file://$PROJECT_DIR$/out"/>
53+
</component>
54+
<component name="SvnBranchConfigurationManager">
55+
<option name="mySupportsUserInfoFilter" value="true"/>
56+
</component>
57+
<component name="VcsDirectoryMappings">
58+
<mapping directory="" vcs=""/>
59+
</component>
60+
<component name="masterDetails">
61+
<states>
62+
<state key="ArtifactsStructureConfigurable.UI">
63+
<UIState>
64+
<splitter-proportions>
65+
<SplitterProportionsDataImpl/>
66+
</splitter-proportions>
67+
<settings/>
68+
</UIState>
69+
</state>
70+
<state key="Copyright.UI">
71+
<UIState>
72+
<splitter-proportions>
73+
<SplitterProportionsDataImpl/>
74+
</splitter-proportions>
75+
</UIState>
76+
</state>
77+
<state key="ProjectJDKs.UI">
78+
<UIState>
79+
<splitter-proportions>
80+
<SplitterProportionsDataImpl>
81+
<option name="proportions">
82+
<list>
83+
<option value="0.2"/>
84+
</list>
85+
</option>
86+
</SplitterProportionsDataImpl>
87+
</splitter-proportions>
88+
<last-edited>1.6</last-edited>
89+
</UIState>
90+
</state>
91+
<state key="ScopeChooserConfigurable.UI">
92+
<UIState>
93+
<splitter-proportions>
94+
<SplitterProportionsDataImpl/>
95+
</splitter-proportions>
96+
<settings/>
97+
</UIState>
98+
</state>
99+
</states>
100+
</component>
101+
</project>

build.gradle

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
plugins {
2+
id "me.champeau.gradle.jmh" version "0.3.0"
3+
}
4+
5+
group 'de.moneysoft'
6+
version '1.0-SNAPSHOT'
7+
8+
9+
apply plugin: 'java'
10+
apply plugin: 'idea'
11+
12+
13+
repositories {
14+
mavenCentral()
15+
}
16+
17+
dependencies {
18+
testCompile 'org.apache.commons:commons-lang3:3.4'
19+
testCompile 'joda-time:joda-time:2.9.3'
20+
testCompile 'org.assertj:assertj-core:3.4.1'
21+
testCompile group: 'junit', name: 'junit', version: '4.11'
22+
}
23+
24+
jmh {
25+
failOnError = true
26+
}
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Sun May 01 11:19:44 CEST 2016
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-all.zip

0 commit comments

Comments
 (0)