| Summary: | [performance] prefer Arrays.equals | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Jörg Kubitz <jkubitz-eclipse> |
| Component: | Core | Assignee: | Jörg Kubitz <jkubitz-eclipse> |
| Status: | VERIFIED FIXED | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | jarthana, julian.honnen, Lars.Vogel, loskutov |
| Version: | 4.20 | ||
| Target Milestone: | 4.20 M1 | ||
| Hardware: | PC | ||
| OS: | Windows 10 | ||
| See Also: |
https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/176984 https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=a055c74e546351cc9356bde8e6c5eb95416f542e |
||
| Whiteboard: | |||
| Bug Depends on: | |||
| Bug Blocks: | 571430 | ||
|
Description
Jörg Kubitz
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/176984 How long were your input strings? 38 chars like: "org.openjdk.jmh.annotations.Benchmark" + randomchar Please try the same benchmark for unqualified names. "Benchmark"+randomchar Benchmark Mode Cnt Score Error Units EqualsUnqualified.testEqualsArraysBegin avgt 5 4,123 ± 0,060 ns/op EqualsUnqualified.testEqualsArraysMid avgt 5 5,005 ± 0,395 ns/op EqualsUnqualified.testEqualsArraysEnd avgt 5 5,931 ± 0,105 ns/op EqualsUnqualified.testEqualsArraysEqual avgt 5 6,216 ± 0,122 ns/op EqualsUnqualified.testEqualsCharOperationEqual avgt 5 8,237 ± 0,278 ns/op EqualsUnqualified.testEqualsCharOperationBegin avgt 5 7,900 ± 0,273 ns/op EqualsUnqualified.testEqualsCharOperationMid avgt 5 5,456 ± 0,219 ns/op EqualsUnqualified.testEqualsCharOperationEnd avgt 5 3,225 ± 0,194 ns/op There is overhead in Arrays.equals but still slightly better then the loop. I would have expected a greater difference in Arrays.equals, but the fully qualified name is probably still a short string for the vectorized implementation. Just for completness (and verification, that length matters): Benchmark Mode Cnt Score Error Units EqualsLong.testEqualsArraysBegin avgt 5 4,405 ± 0,108 ns/op EqualsLong.testEqualsArraysMid avgt 5 18,018 ± 0,398 ns/op EqualsLong.testEqualsArraysEnd avgt 5 18,832 ± 0,293 ns/op EqualsLong.testEqualsArraysEqual avgt 5 18,904 ± 0,580 ns/op EqualsLong.testEqualsCharOperationEqual avgt 5 108,430 ± 3,130 ns/op EqualsLong.testEqualsCharOperationBegin avgt 5 111,048 ± 3,234 ns/op EqualsLong.testEqualsCharOperationMid avgt 5 62,427 ± 1,168 ns/op EqualsLong.testEqualsCharOperationEnd avgt 5 3,175 ± 0,069 ns/op for length 385 Gerrit change https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/176984 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=a055c74e546351cc9356bde8e6c5eb95416f542e Thanks, Jörg! Verified for 4.20 M1 by code inspection |