-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[LANG-1576] refine StringUtils.chomp #565
base: master
Are you sure you want to change the base?
Conversation
If I understand the benchmark correctly, the New method is approx 3% slower for Test1 and about 2% faster for Test2. |
Yes, it isn't. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At current this benchmark is not testing the differences between the methods in the manner recommended by JMH. The results for test1 and test2 for new and old methods are within the 99.9% confidence level for each and thus are inconclusive.
I would improve the test to hit all code paths and ensure the result of the chomp method is used.
src/test/java/org/apache/commons/lang3/StringUtilsChompTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/apache/commons/lang3/StringUtilsChompTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/apache/commons/lang3/StringUtilsChompTest.java
Outdated
Show resolved
Hide resolved
The JMH results are very long and obscure the thread of the PR. Is it possible to post just the summary inline, with a link to the full results in an attachment? |
441603a
to
833bfc0
Compare
@sebbASF |
As a result:
The test shows it is almost even speed when ends with \r or \n, but 6.7% faster when ends with no \r nor \n,which I think is the most cases we use the function. |
src/test/java/org/apache/commons/lang3/StringUtilsChompTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/apache/commons/lang3/StringUtilsChompTest.java
Outdated
Show resolved
Hide resolved
performance tests refined.
|
src/test/java/org/apache/commons/lang3/StringUtilsChompTest.java
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Thanks - much easier to see what has been changed now. I don't think the RandomStrings test is a fair benchmark. |
Actually it is fair. |
Sorry, I see now that the strings do have a mix of CR and LF endings (or neither). As to the change itself, it looks fine, but IMO the benchmark needs some work. |
@sebbASF
The behaviour of the method depends only on the last one or two characters (and the length). |
I think the current huge list of input strings is more about testing functionality rather than performance. The method only cares about 3 characters: CR, LF or something else (unless it has a bug). It also needs to test the length, because that is used when doing the substring. |
Not really.
While 3,4,5 be actually handled by a same
So you mean we should add test for some specific length of strings? |
You are correct - I was forgetting that the characters could be missing. As to testing the length, yes I think we do need to test for various lengths. |
Hi.
|
e8eb61c
to
30a86be
Compare
30a86be
to
46350d4
Compare
@garydgregory rebased. please find some time to review. thanks. |
as title.