Hi: I did ran a quick JMH micro-benchmark (for what it's worth) on both approaches. The results favor StringUtils.stripStart() over regex.
(attached benchmark project .zip file) Output: # JMH version: 1.21 # VM version: JDK 10.0.2, Java HotSpot(TM) 64-Bit Server VM, 10.0.2+13 # VM invoker: /usr/lib/jvm/java-10-oracle/bin/java # VM options: <none> # Warmup: 5 iterations, 10 s each # Measurement: 5 iterations, 10 s each # Timeout: 10 min per iteration # Threads: 1 thread, will synchronize iterations # Benchmark mode: Throughput, ops/time # Benchmark: org.sample.MyBenchmark.testRegex # Run progress: 0,00% complete, ETA 00:16:40 # Fork: 1 of 5 # Warmup Iteration 1: 115592,945 ops/s # Warmup Iteration 2: 122466,987 ops/s # Warmup Iteration 3: 122168,413 ops/s # Warmup Iteration 4: 123296,590 ops/s # Warmup Iteration 5: 121609,324 ops/s Iteration 1: 122126,768 ops/s Iteration 2: 123127,808 ops/s Iteration 3: 122700,768 ops/s Iteration 4: 123601,980 ops/s Iteration 5: 123357,611 ops/s # Run progress: 10,00% complete, ETA 00:15:06 # Fork: 2 of 5 # Warmup Iteration 1: 115779,273 ops/s # Warmup Iteration 2: 122535,724 ops/s # Warmup Iteration 3: 123753,240 ops/s # Warmup Iteration 4: 122713,109 ops/s # Warmup Iteration 5: 123618,475 ops/s Iteration 1: 123314,055 ops/s Iteration 2: 123142,400 ops/s Iteration 3: 121928,614 ops/s Iteration 4: 122214,377 ops/s Iteration 5: 123543,852 ops/s # Run progress: 20,00% complete, ETA 00:13:25 # Fork: 3 of 5 # Warmup Iteration 1: 114917,291 ops/s # Warmup Iteration 2: 121140,667 ops/s # Warmup Iteration 3: 118295,250 ops/s # Warmup Iteration 4: 118386,423 ops/s # Warmup Iteration 5: 118439,461 ops/s Iteration 1: 117842,336 ops/s Iteration 2: 118337,507 ops/s Iteration 3: 118294,871 ops/s Iteration 4: 118656,349 ops/s Iteration 5: 118558,792 ops/s # Run progress: 30,00% complete, ETA 00:11:44 # Fork: 4 of 5 # Warmup Iteration 1: 115428,718 ops/s # Warmup Iteration 2: 121519,510 ops/s # Warmup Iteration 3: 123656,289 ops/s # Warmup Iteration 4: 123731,525 ops/s # Warmup Iteration 5: 123664,813 ops/s Iteration 1: 122795,328 ops/s Iteration 2: 123292,329 ops/s Iteration 3: 123914,332 ops/s Iteration 4: 123725,241 ops/s Iteration 5: 123525,873 ops/s # Run progress: 40,00% complete, ETA 00:10:03 # Fork: 5 of 5 # Warmup Iteration 1: 114873,436 ops/s # Warmup Iteration 2: 120492,746 ops/s # Warmup Iteration 3: 122673,036 ops/s # Warmup Iteration 4: 121569,231 ops/s # Warmup Iteration 5: 122378,009 ops/s Iteration 1: 121805,248 ops/s Iteration 2: 122254,162 ops/s Iteration 3: 122293,226 ops/s Iteration 4: 121449,921 ops/s Iteration 5: 121989,101 ops/s Result "org.sample.MyBenchmark.testRegex": 121911,714 ±(99.9%) 1456,002 ops/s [Average] (min, avg, max) = (117842,336, 121911,714, 123914,332), stdev = 1943,721 CI (99.9%): [120455,712, 123367,716] (assumes normal distribution) # JMH version: 1.21 # VM version: JDK 10.0.2, Java HotSpot(TM) 64-Bit Server VM, 10.0.2+13 # VM invoker: /usr/lib/jvm/java-10-oracle/bin/java # VM options: <none> # Warmup: 5 iterations, 10 s each # Measurement: 5 iterations, 10 s each # Timeout: 10 min per iteration # Threads: 1 thread, will synchronize iterations # Benchmark mode: Throughput, ops/time # Benchmark: org.sample.MyBenchmark.testStringUItilsStripStart # Run progress: 50,00% complete, ETA 00:08:23 # Fork: 1 of 5 # Warmup Iteration 1: 1039951,283 ops/s # Warmup Iteration 2: 1079678,801 ops/s # Warmup Iteration 3: 903261,012 ops/s # Warmup Iteration 4: 926671,364 ops/s # Warmup Iteration 5: 933659,789 ops/s Iteration 1: 884965,824 ops/s Iteration 2: 889218,414 ops/s Iteration 3: 936928,275 ops/s Iteration 4: 884544,948 ops/s Iteration 5: 910224,385 ops/s # Run progress: 60,00% complete, ETA 00:06:42 # Fork: 2 of 5 # Warmup Iteration 1: 962278,822 ops/s # Warmup Iteration 2: 988250,807 ops/s # Warmup Iteration 3: 870544,716 ops/s # Warmup Iteration 4: 863789,867 ops/s # Warmup Iteration 5: 864501,466 ops/s Iteration 1: 863536,313 ops/s Iteration 2: 868579,343 ops/s Iteration 3: 868197,634 ops/s Iteration 4: 866415,349 ops/s Iteration 5: 866593,399 ops/s # Run progress: 70,00% complete, ETA 00:05:01 # Fork: 3 of 5 # Warmup Iteration 1: 1041356,608 ops/s # Warmup Iteration 2: 1053943,657 ops/s # Warmup Iteration 3: 965779,373 ops/s # Warmup Iteration 4: 974967,751 ops/s # Warmup Iteration 5: 969837,627 ops/s Iteration 1: 951069,998 ops/s Iteration 2: 970677,240 ops/s Iteration 3: 951033,637 ops/s Iteration 4: 951622,347 ops/s Iteration 5: 955366,302 ops/s # Run progress: 80,00% complete, ETA 00:03:21 # Fork: 4 of 5 # Warmup Iteration 1: 909946,836 ops/s # Warmup Iteration 2: 944886,834 ops/s # Warmup Iteration 3: 850848,610 ops/s # Warmup Iteration 4: 852793,912 ops/s # Warmup Iteration 5: 852968,776 ops/s Iteration 1: 842741,985 ops/s Iteration 2: 849709,794 ops/s Iteration 3: 845358,191 ops/s Iteration 4: 840891,662 ops/s Iteration 5: 851067,146 ops/s # Run progress: 90,00% complete, ETA 00:01:40 # Fork: 5 of 5 # Warmup Iteration 1: 963774,613 ops/s # Warmup Iteration 2: 975159,116 ops/s # Warmup Iteration 3: 881336,856 ops/s # Warmup Iteration 4: 888053,064 ops/s # Warmup Iteration 5: 892528,040 ops/s Iteration 1: 886145,892 ops/s Iteration 2: 895643,626 ops/s Iteration 3: 882961,243 ops/s Iteration 4: 891835,477 ops/s Iteration 5: 873767,534 ops/s Result "org.sample.MyBenchmark.testStringUItilsStripStart": 891163,838 ±(99.9%) 29627,858 ops/s [Average] (min, avg, max) = (840891,662, 891163,838, 970677,240), stdev = 39552,343 CI (99.9%): [861535,980, 920791,697] (assumes normal distribution) # Run complete. Total time: 00:16:46 REMEMBER: The numbers below are just data. To gain reusable insights, you need to follow up on why the numbers are the way they are. Use profilers (see -prof, -lprof), design factorial experiments, perform baseline and negative tests that provide experimental control, make sure the benchmarking environment is safe on JVM/OS/HW level, ask for reviews from the domain experts. Do not assume the numbers tell you what you want them to tell. Benchmark Mode Cnt Score Error Units MyBenchmark.testRegex thrpt 25 121911,714 ± 1456,002 ops/s MyBenchmark.testStringUItilsStripStart thrpt 25 891163,838 ± 29627,858 ops/s El jue., 21 de mar. de 2019 a la(s) 19:41, Hervé BOUTEMY ( [email protected]) escribió: > "use int or long instead of BigIntegers for little numbers in > ComparableVersion" > https://issues.apache.org/jira/browse/MNG-6572 > > implementation: > https://github.com/apache/maven/commits/MNG-6572 > > there is just a question: keep the second commit (use regexp) or not? I'm > not > convinced it is an enhancement > > any seconder? > > Regards, > > Hervé > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
<<attachment: testStripLeadZero.zip>>
--------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
