-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speed up converting of temporal accessor to zoned date time #37915
Merged
spinscale
merged 13 commits into
elastic:master
from
spinscale:1901-fix-timezone-parsing-performance-issue
Jan 31, 2019
Merged
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6a997f3
Speed up converting of temporal accessor to zoned date time
spinscale 31d04bf
Merge branch 'master' into 1901-fix-timezone-parsing-performance-issue
spinscale 91ba291
Merge branch 'master' into 1901-fix-timezone-parsing-performance-issue
spinscale 9b804ec
Merge branch 'master' into 1901-fix-timezone-parsing-performance-issue
spinscale 45a18d8
Merge branch 'master' into 1901-fix-timezone-parsing-performance-issue
spinscale b498175
Merge branch 'master' into 1901-fix-timezone-parsing-performance-issue
spinscale fa3304b
incorporate review comments
spinscale 0bb19c3
refactor out another forbidden method
spinscale 2565c5c
change parameter order
spinscale 9071e3e
Merge branch 'master' into 1901-fix-timezone-parsing-performance-issue
spinscale 359b71b
remove unused code
spinscale ad550a2
Merge branch 'master' into 1901-fix-timezone-parsing-performance-issue
spinscale 1ad141c
remove unneeded tests
spinscale File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...rks/src/main/java/org/elasticsearch/benchmark/time/DateFormatterToZonedTimeBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.elasticsearch.benchmark.time; | ||
|
||
import org.elasticsearch.common.time.DateFormatter; | ||
import org.elasticsearch.common.time.DateFormatters; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Fork; | ||
import org.openjdk.jmh.annotations.Measurement; | ||
import org.openjdk.jmh.annotations.Mode; | ||
import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.openjdk.jmh.annotations.Warmup; | ||
|
||
import java.time.temporal.TemporalAccessor; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
@Fork(3) | ||
@Warmup(iterations = 10) | ||
@Measurement(iterations = 10) | ||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(TimeUnit.NANOSECONDS) | ||
@State(Scope.Benchmark) | ||
@SuppressWarnings("unused") //invoked by benchmarking framework | ||
public class DateFormatterToZonedTimeBenchmark { | ||
|
||
private final TemporalAccessor accessor = DateFormatter.forPattern("epoch_millis").parse("1234567890"); | ||
|
||
@Benchmark | ||
public TemporalAccessor benchmarkToZonedDateTime() { | ||
// benchmark an accessor that does not contain a timezone | ||
// this used to throw an exception earlier and thus was very very slow | ||
return DateFormatters.from(accessor); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we use the "current" year in the specified time zone instead of UTC? Wouldn't we otherwise either use the next or the previous year around the turn of the year?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I resembled the joda time behaviour here. I also created a test that compares joda time with java time to make sure the output is the same