diff options
author | Neil Fuller <nfuller@google.com> | 2015-04-15 16:40:51 +0100 |
---|---|---|
committer | Neil Fuller <nfuller@google.com> | 2015-04-16 11:54:33 +0100 |
commit | 12fbbc16959d078dde23b3b15c8d3d127ef33507 (patch) | |
tree | 9408e161dced38ea6e394f6597839361796c7dd6 /benchmarks | |
parent | 0ed6c7db9f92dc3f0082328637f8550e87099b3d (diff) | |
download | libcore-12fbbc16959d078dde23b3b15c8d3d127ef33507.zip libcore-12fbbc16959d078dde23b3b15c8d3d127ef33507.tar.gz libcore-12fbbc16959d078dde23b3b15c8d3d127ef33507.tar.bz2 |
Use ICU4J more in DateIntervalFormat and RelativeDateTimeFormatter
General strategy: Switch to ICU classes for Calendar, and generally
use ICU classes earlier to avoid multiple creations.
This also incorporates some feedback from narayan@ from
https://android-review.googlesource.com/#/c/145662/
Some small optimizations applied but the goal was not to make it
much faster, just to confirm it wasn't much slower. It has sped up
some methods, and slowed down others, but not much difference in
absolute terms.
All times in microseconds measured on a mako.
Original:
RelativeDateTimeFormatter_getRelativeDateTimeString 582.4
RelativeDateTimeFormatter_getRelativeDateTimeString_ABBREV 603.2
RelativeDateTimeFormatter_getRelativeTimeSpanString 39.9
RelativeDateTimeFormatter_getRelativeTimeSpanString_ABBREV 39.1
After:
RelativeDateTimeFormatter_getRelativeDateTimeString 207.2
RelativeDateTimeFormatter_getRelativeDateTimeString_ABBREV 218.2
RelativeDateTimeFormatter_getRelativeTimeSpanString 70.5
RelativeDateTimeFormatter_getRelativeTimeSpanString_ABBREV 67.4
Original:
DateIntervalFormat_formatDateRange_DATE 290
DateIntervalFormat_formatDateRange_DATE_TIME 298
DateIntervalFormat_formatDateRange_TIME 276
After:
DateIntervalFormat_formatDateRange_DATE 244
DateIntervalFormat_formatDateRange_DATE_TIME 256
DateIntervalFormat_formatDateRange_TIME 208
Change-Id: If043bd55ffec37ed2735aa1593f327b38749218c
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/src/benchmarks/regression/DateIntervalFormatBenchmark.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/benchmarks/src/benchmarks/regression/DateIntervalFormatBenchmark.java b/benchmarks/src/benchmarks/regression/DateIntervalFormatBenchmark.java index 02d8f97..e84c287 100644 --- a/benchmarks/src/benchmarks/regression/DateIntervalFormatBenchmark.java +++ b/benchmarks/src/benchmarks/regression/DateIntervalFormatBenchmark.java @@ -18,14 +18,14 @@ package benchmarks.regression; import com.google.caliper.SimpleBenchmark; -import java.util.Locale; -import java.util.TimeZone; +import android.icu.util.ULocale; +import android.icu.util.TimeZone; import static libcore.icu.DateIntervalFormat.*; public class DateIntervalFormatBenchmark extends SimpleBenchmark { public void timeDateIntervalFormat_formatDateRange_DATE(int reps) throws Exception { - Locale l = Locale.US; + ULocale l = ULocale.US; TimeZone utc = TimeZone.getTimeZone("UTC"); int flags = FORMAT_SHOW_DATE | FORMAT_SHOW_WEEKDAY; @@ -35,7 +35,7 @@ public class DateIntervalFormatBenchmark extends SimpleBenchmark { } public void timeDateIntervalFormat_formatDateRange_TIME(int reps) throws Exception { - Locale l = Locale.US; + ULocale l = ULocale.US; TimeZone utc = TimeZone.getTimeZone("UTC"); int flags = FORMAT_SHOW_TIME | FORMAT_24HOUR; @@ -45,7 +45,7 @@ public class DateIntervalFormatBenchmark extends SimpleBenchmark { } public void timeDateIntervalFormat_formatDateRange_DATE_TIME(int reps) throws Exception { - Locale l = Locale.US; + ULocale l = ULocale.US; TimeZone utc = TimeZone.getTimeZone("UTC"); int flags = FORMAT_SHOW_DATE | FORMAT_SHOW_WEEKDAY | FORMAT_SHOW_TIME | FORMAT_24HOUR; |