CharacterBenchmark.java revision e236301e5fc778bffe1748ed80d7936e6c807012
17fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin/* 27fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin * Copyright (C) 2009 Google Inc. 37fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin * 47fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin * Licensed under the Apache License, Version 2.0 (the "License"); 57fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin * you may not use this file except in compliance with the License. 67fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin * You may obtain a copy of the License at 77fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin * 87fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin * http://www.apache.org/licenses/LICENSE-2.0 97fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin * 107fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin * Unless required by applicable law or agreed to in writing, software 117fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin * distributed under the License is distributed on an "AS IS" BASIS, 127fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 137fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin * See the License for the specific language governing permissions and 147fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin * limitations under the License. 157fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin */ 167fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 177fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffinpackage examples; 187fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 19e236301e5fc778bffe1748ed80d7936e6c807012Paul Duffinimport com.google.caliper.BeforeExperiment; 20e236301e5fc778bffe1748ed80d7936e6c807012Paul Duffinimport com.google.caliper.Benchmark; 217fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffinimport com.google.caliper.Param; 227fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 237fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin/** 247fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin * Tests various Character methods, intended for testing multiple 257fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin * implementations against each other. 267fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin */ 27e236301e5fc778bffe1748ed80d7936e6c807012Paul Duffinpublic class CharacterBenchmark { 287fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 297fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin @Param private CharacterSet characterSet; 307fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 317fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin @Param private Overload overload; 327fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 337fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin private char[] chars; 347fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 35e236301e5fc778bffe1748ed80d7936e6c807012Paul Duffin @BeforeExperiment void setUp() throws Exception { 367fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin this.chars = characterSet.chars; 377fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 387fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 397fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin public enum Overload { CHAR, INT } 407fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 417fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin public enum CharacterSet { 427fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin ASCII(128), 437fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin UNICODE(65536); 447fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin final char[] chars; 457fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin CharacterSet(int size) { 467fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin this.chars = new char[65536]; 477fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < 65536; ++i) { 487fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin chars[i] = (char) (i % size); 497fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 507fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 517fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 527fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 537fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin // A fake benchmark to give us a baseline. 54e236301e5fc778bffe1748ed80d7936e6c807012Paul Duffin @Benchmark boolean isSpace(int reps) { 557fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin boolean dummy = false; 567fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin if (overload == Overload.CHAR) { 577fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 587fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 597fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin dummy ^= ((char) ch == ' '); 607fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 617fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 627fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } else { 637fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 647fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 657fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin dummy ^= (ch == ' '); 667fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 677fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 687fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 697fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin return dummy; 707fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 717fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 72e236301e5fc778bffe1748ed80d7936e6c807012Paul Duffin @Benchmark void digit(int reps) { 737fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin if (overload == Overload.CHAR) { 747fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 757fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 767fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.digit(chars[ch], 10); 777fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 787fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 797fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } else { 807fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 817fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 827fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.digit((int) chars[ch], 10); 837fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 847fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 857fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 867fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 877fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 88e236301e5fc778bffe1748ed80d7936e6c807012Paul Duffin @Benchmark void getNumericValue(int reps) { 897fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin if (overload == Overload.CHAR) { 907fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 917fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 927fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.getNumericValue(chars[ch]); 937fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 947fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 957fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } else { 967fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 977fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 987fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.getNumericValue((int) chars[ch]); 997fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1007fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1017fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1027fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1037fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 104e236301e5fc778bffe1748ed80d7936e6c807012Paul Duffin @Benchmark void isDigit(int reps) { 1057fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin if (overload == Overload.CHAR) { 1067fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 1077fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 1087fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.isDigit(chars[ch]); 1097fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1107fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1117fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } else { 1127fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 1137fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 1147fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.isDigit((int) chars[ch]); 1157fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1167fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1177fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1187fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1197fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 120e236301e5fc778bffe1748ed80d7936e6c807012Paul Duffin @Benchmark void isIdentifierIgnorable(int reps) { 1217fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin if (overload == Overload.CHAR) { 1227fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 1237fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 1247fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.isIdentifierIgnorable(chars[ch]); 1257fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1267fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1277fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } else { 1287fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 1297fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 1307fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.isIdentifierIgnorable((int) chars[ch]); 1317fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1327fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1337fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1347fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1357fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 136e236301e5fc778bffe1748ed80d7936e6c807012Paul Duffin @Benchmark void isJavaIdentifierPart(int reps) { 1377fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin if (overload == Overload.CHAR) { 1387fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 1397fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 1407fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.isJavaIdentifierPart(chars[ch]); 1417fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1427fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1437fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } else { 1447fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 1457fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 1467fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.isJavaIdentifierPart((int) chars[ch]); 1477fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1487fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1497fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1507fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1517fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 152e236301e5fc778bffe1748ed80d7936e6c807012Paul Duffin @Benchmark void isJavaIdentifierStart(int reps) { 1537fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin if (overload == Overload.CHAR) { 1547fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 1557fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 1567fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.isJavaIdentifierStart(chars[ch]); 1577fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1587fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1597fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } else { 1607fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 1617fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 1627fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.isJavaIdentifierStart((int) chars[ch]); 1637fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1647fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1657fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1667fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1677fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 168e236301e5fc778bffe1748ed80d7936e6c807012Paul Duffin @Benchmark void isLetter(int reps) { 1697fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin if (overload == Overload.CHAR) { 1707fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 1717fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 1727fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.isLetter(chars[ch]); 1737fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1747fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1757fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } else { 1767fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 1777fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 1787fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.isLetter((int) chars[ch]); 1797fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1807fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1817fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1827fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1837fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 184e236301e5fc778bffe1748ed80d7936e6c807012Paul Duffin @Benchmark void isLetterOrDigit(int reps) { 1857fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin if (overload == Overload.CHAR) { 1867fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 1877fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 1887fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.isLetterOrDigit(chars[ch]); 1897fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1907fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1917fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } else { 1927fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 1937fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 1947fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.isLetterOrDigit((int) chars[ch]); 1957fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1967fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1977fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1987fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 1997fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 200e236301e5fc778bffe1748ed80d7936e6c807012Paul Duffin @Benchmark void isLowerCase(int reps) { 2017fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin if (overload == Overload.CHAR) { 2027fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 2037fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 2047fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.isLowerCase(chars[ch]); 2057fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2067fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2077fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } else { 2087fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 2097fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 2107fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.isLowerCase((int) chars[ch]); 2117fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2127fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2137fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2147fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2157fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 216e236301e5fc778bffe1748ed80d7936e6c807012Paul Duffin @Benchmark void isSpaceChar(int reps) { 2177fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin if (overload == Overload.CHAR) { 2187fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 2197fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 2207fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.isSpaceChar(chars[ch]); 2217fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2227fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2237fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } else { 2247fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 2257fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 2267fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.isSpaceChar((int) chars[ch]); 2277fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2287fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2297fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2307fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2317fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 232e236301e5fc778bffe1748ed80d7936e6c807012Paul Duffin @Benchmark void isUpperCase(int reps) { 2337fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin if (overload == Overload.CHAR) { 2347fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 2357fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 2367fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.isUpperCase(chars[ch]); 2377fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2387fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2397fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } else { 2407fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 2417fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 2427fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.isUpperCase((int) chars[ch]); 2437fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2447fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2457fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2467fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2477fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 248e236301e5fc778bffe1748ed80d7936e6c807012Paul Duffin @Benchmark void isWhitespace(int reps) { 2497fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin if (overload == Overload.CHAR) { 2507fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 2517fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 2527fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.isWhitespace(chars[ch]); 2537fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2547fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2557fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } else { 2567fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 2577fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 2587fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.isWhitespace((int) chars[ch]); 2597fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2607fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2617fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2627fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2637fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 264e236301e5fc778bffe1748ed80d7936e6c807012Paul Duffin @Benchmark void toLowerCase(int reps) { 2657fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin if (overload == Overload.CHAR) { 2667fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 2677fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 2687fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.toLowerCase(chars[ch]); 2697fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2707fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2717fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } else { 2727fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 2737fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 2747fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.toLowerCase((int) chars[ch]); 2757fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2767fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2777fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2787fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2797fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin 280e236301e5fc778bffe1748ed80d7936e6c807012Paul Duffin @Benchmark void toUpperCase(int reps) { 2817fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin if (overload == Overload.CHAR) { 2827fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 2837fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 2847fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.toUpperCase(chars[ch]); 2857fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2867fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2877fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } else { 2887fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int i = 0; i < reps; ++i) { 2897fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin for (int ch = 0; ch < 65536; ++ch) { 2907fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin Character.toUpperCase((int) chars[ch]); 2917fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2927fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2937fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2947fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin } 2957fc0b45feb5ac6191547bb0a175a718cb41ec4f9Paul Duffin} 296