GitHub user librucha opened a pull request: https://github.com/apache/commons-lang/pull/27
Reimplemented normalize space Hi. I reimplemented normalize space method of String utils, because regexp is much more rich operation than array traversing and I use this normalization often. Here is benchmark created using google caliper. 0% Scenario{vm=java, trial=0, benchmark=ApacheNormalize, length=0} 1553.39 ns; Ï=142.64 ns @ 10 trials 13% Scenario{vm=java, trial=0, benchmark=NewNormalize, length=0} 114.80 ns; Ï=1.00 ns @ 3 trials 25% Scenario{vm=java, trial=0, benchmark=ApacheNormalize, length=10} 1513.44 ns; Ï=133.58 ns @ 10 trials 38% Scenario{vm=java, trial=0, benchmark=NewNormalize, length=10} 114.49 ns; Ï=1.05 ns @ 3 trials 50% Scenario{vm=java, trial=0, benchmark=ApacheNormalize, length=100} 1545.23 ns; Ï=107.97 ns @ 10 trials 63% Scenario{vm=java, trial=0, benchmark=NewNormalize, length=100} 114.28 ns; Ï=0.65 ns @ 3 trials 75% Scenario{vm=java, trial=0, benchmark=ApacheNormalize, length=1000} 1550.35 ns; Ï=138.57 ns @ 10 trials 88% Scenario{vm=java, trial=0, benchmark=NewNormalize, length=1000} 115.16 ns; Ï=1.14 ns @ 3 trials benchmark length ns linear runtime ApacheNormalize 0 1553 ============================== ApacheNormalize 10 1513 ============================= ApacheNormalize 100 1545 ============================= ApacheNormalize 1000 1550 ============================= NewNormalize 0 115 == NewNormalize 10 114 == NewNormalize 100 114 == NewNormalize 1000 115 == vm: java trial: 0 You can merge this pull request into a Git repository by running: $ git pull https://github.com/librucha/commons-lang trunk Alternatively you can review and apply these changes as the patch at: https://github.com/apache/commons-lang/pull/27.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #27 ---- commit 07437c259692e6f6ecdcef86411586df6800cffd Author: Libor Ondrusek <libor.ondru...@artin.cz> Date: 2014-06-20T09:36:43Z Reimplemented normalize space ---- --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org