[
https://issues.apache.org/jira/browse/HTTPCLIENT-1471?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14133425#comment-14133425
]
Joseph Walton commented on HTTPCLIENT-1471:
-------------------------------------------
There's definitely some overhead for boxing; here's what I got from [the
microbenchmark I
ran|https://microbenchmarks.appspot.com/runs/3ac64b7d-07db-4721-8c8f-90c06a551f12#r:scenario.benchmarkSpec.methodName]
with [Caliper|https://code.google.com/p/caliper/]:
||Method||description||runtime (ns)||
|WithArrayIteration|Linear search over {{int[]}}|5.395|
|WithCode|Inline {{if (code == ...}}|0.403|
|WithSet|{{valid.contains(status)}}|6.010|
|WithSortedArraySearch|Arrays.binarySearch|4.228|
It may not be worth the change.
> ResponseCachingPolicy - eliminate boxing and HashSet
> ----------------------------------------------------
>
> Key: HTTPCLIENT-1471
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1471
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Components: HttpCache
> Reporter: Sebb
> Priority: Minor
> Fix For: 4.4 Final
>
>
> ResponseCachingPolicy uses 2 HashSets containing a few Integers each for
> matching int values.
> This involves lots of boxing plus the overhead of the hashSet.
> Since the numbers of integers involved is very small - at most 6 - it seems
> unnecessary to use hashing. A linear search would likely be quicker.
> If the number of entries were to be rather larger, then Arrays#binarySearch
> might be better.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]