[
https://issues.apache.org/jira/browse/LANG-1576?focusedWorklogId=463433&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-463433
]
ASF GitHub Bot logged work on LANG-1576:
----------------------------------------
Author: ASF GitHub Bot
Created on: 26/Jul/20 23:29
Start Date: 26/Jul/20 23:29
Worklog Time Spent: 10m
Work Description: XenoAmess commented on a change in pull request #565:
URL: https://github.com/apache/commons-lang/pull/565#discussion_r460586849
##########
File path: src/test/java/org/apache/commons/lang3/StringUtilsChompTest.java
##########
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.lang3;
+
+import java.util.concurrent.TimeUnit;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.State;
+import static org.apache.commons.lang3.StringUtils.EMPTY;
+import static org.apache.commons.lang3.StringUtils.isEmpty;
+import static org.apache.commons.lang3.StringUtils.length;
+
+/**
+ * Test to show whether using BitSet for removeAll() methods is faster than
using HashSet.
+ */
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@State(Scope.Thread)
+public class StringUtilsChompTest {
+
+ private static final String string1 = "\r";
+ private static final String string2 = buildString2();
+
+ private static String buildString2() {
+ StringBuilder stringBuilder = new StringBuilder();
+ for (int i = 0; i < 100000; i++) {
+ stringBuilder.append('0');
+ stringBuilder.append('\r');
+ stringBuilder.append('0');
+ stringBuilder.append('\n');
+ stringBuilder.append('0');
+ stringBuilder.append('\r');
+ stringBuilder.append('\n');
+ }
+ return stringBuilder.toString();
+ }
+
+ @Benchmark
+ public void test1Old() {
+ chompOld(string1);
Review comment:
@aherbert
> Otherwise there is nothing to prevent the JVM from not running your chomp
methods as the result is discarded.
Is there some material/document about this?
I ask because seems I never observed this kind of thing happened...
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 463433)
Time Spent: 2h 20m (was: 2h 10m)
> refine StringUtils.chomp
> ------------------------
>
> Key: LANG-1576
> URL: https://issues.apache.org/jira/browse/LANG-1576
> Project: Commons Lang
> Issue Type: Sub-task
> Reporter: Jin Xu
> Priority: Minor
> Time Spent: 2h 20m
> Remaining Estimate: 0h
>
> [https://github.com/apache/commons-lang/pull/565]
--
This message was sent by Atlassian Jira
(v8.3.4#803005)