diff options
author | Przemyslaw Szczepaniak <pszczepaniak@google.com> | 2016-04-07 13:31:21 +0100 |
---|---|---|
committer | Przemyslaw Szczepaniak <pszczepaniak@google.com> | 2016-04-07 14:51:51 +0100 |
commit | 3fdfc1f28f4b42ed4a6fb1a1111942c8134fd9f6 (patch) | |
tree | bbf188fe64fa79aea0406a45b2cab49e17c8ea00 /benchmarks | |
parent | 22fda0241e38299569017307241bb2180cae351d (diff) |
Add Character#digit(int, int) fastpath
Added a java fastpath for common cases in the
Character#digit(int, int) method. Improves performance
of conversions from string to numeric types.
Bug: 28008616
Change-Id: I28aacba520c3f51a5cb5a59e51d4ae593daa551c
(cherry picked from commit cff29861633f2d4907b79644dace4a6790982faf)
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/src/benchmarks/regression/IntegerBenchmark.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/benchmarks/src/benchmarks/regression/IntegerBenchmark.java b/benchmarks/src/benchmarks/regression/IntegerBenchmark.java index f7f97c7369..c9614d4f3d 100644 --- a/benchmarks/src/benchmarks/regression/IntegerBenchmark.java +++ b/benchmarks/src/benchmarks/regression/IntegerBenchmark.java @@ -133,4 +133,16 @@ public class IntegerBenchmark { } return t; } + + public int timeIntegerValueOf(int reps) throws Exception { + String[] intStrings = new String[]{"0", "1", "12", "123", "1234", "12345", + "123456", "1234567", "12345678"}; + int t = 0; + for (int i = 0; i < reps; ++i) { + for (int j = 0; j < intStrings.length; ++j) { + t += Integer.valueOf(intStrings[j]); + } + } + return t; + } } |