diff options
author | Anton Hansson <hansson@google.com> | 2018-02-14 15:32:38 +0000 |
---|---|---|
committer | Anton Hansson <hansson@google.com> | 2018-02-15 17:22:08 +0000 |
commit | 4e1eba3255f27c0f477a1a49f8c331dd53e8a39b (patch) | |
tree | 964deeeca5ffa71308650dacd26be3e6b9c59904 /benchmarks | |
parent | 526cd9137d3ac3b03f8045442ea39d970bda7e88 (diff) |
Remove cachedLocaleData from DecimalFormatSymbols.
Only takes a ~7 microseconds to reconstruct, and aligns this class
closer to upstream. Also dubious if repeatedly reconstructing the
same DFS is a use case worth optimizing for.
before
Experiment {instrument=runtime, benchmarkMethod=time_instantiation, vm=default, parameters={}}
Results:
runtime(ns): min=16011.69, 1st qu.=16011.69, median=16011.69, mean=16011.69, 3rd qu.=16011.69, max=16011.69
after
Experiment {instrument=runtime, benchmarkMethod=time_instantiation, vm=default, parameters={}}
Results:
runtime(ns): min=23865.50, 1st qu.=23865.50, median=23865.50, mean=23865.50, 3rd qu.=23865.50, max=23865.50
Also see upstream commit http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/rev/1d7a6adf499f.
Bug: 31930415
Test: ran CtsLibcoreTests & benchmark
Change-Id: I0966125de1690bd0c14f03b190049e7f6948f402
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/src/benchmarks/regression/DecimalFormatSymbolsBenchmark.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/benchmarks/src/benchmarks/regression/DecimalFormatSymbolsBenchmark.java b/benchmarks/src/benchmarks/regression/DecimalFormatSymbolsBenchmark.java new file mode 100644 index 0000000000..381b9e14b2 --- /dev/null +++ b/benchmarks/src/benchmarks/regression/DecimalFormatSymbolsBenchmark.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed 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 benchmarks.regression; + +import java.text.DecimalFormatSymbols; +import java.util.Locale; + +public class DecimalFormatSymbolsBenchmark { + + private static Locale locale = Locale.getDefault(Locale.Category.FORMAT); + + public void time_instantiation(int reps) { + for (int i = 0; i < reps; i++) { + new DecimalFormatSymbols(locale); + } + } +} |