Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #28376
| From | Mike Amling <mamling@chaff.us> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Benchmarking hashcode algorithms |
| Date | 2014-05-05 11:17 -0500 |
| Message-ID | <bsprrfFddd2U1@mid.individual.net> (permalink) |
| References | <klnnl9ls2ovfnt6slsp4hsh6tcig3j5ka9@4ax.com> <b71ol91g81ig0u3o2rkgete4ltj9m100r5@4ax.com> |
On 4/26/14 2:24 PM, Roedy Green wrote: > Here are the latest set of results. There are 100 times faster than in > the previous cut. I was using 1_000_000d to convert from ns to seconds > instead of 1_000_000_000d. Serves me right for not using TimeUnit. > > 1. These are all very fast. For my purposes implementing cache, the > speed is negligible. I have to compute hashes on only 10,000 to > 20,000 files. > > 2. Sun's code works on a string directly. Most hashing require you to > convert the String to a byte first, which is probably as much work a > computing the hash itself. > > 3. Any kind of benchmark code because it does nothing useful can be > optimised out of existence be a clever compiler. I took no measures to > defeat that. > > 4. I also discovered that Adler is not so hot for collisions. > Yep. > ... > > Time to compute 25,000,000 iterations of 32-bit String.hashCode was > 0.393 seconds. > There were 0 collisions in 50,000 filenames > ------ > Time to compute 25,000,000 iterations of 32-bit FNV1a32 was 5.044 > seconds. > There were 1 collisions in 50,000 filenames > ------ > ... Did you write out the code that Java uses to compute String.hashCode, or did you just call s.hashCode()? s.hashCode() could have been precomputed and cached. Did you implement using all 16 bits of each char of the String or only the low-order 8 bits? Mike Amling -- SmFtZXMgTWFkaXNvbiBpcyB1bmRlcnJhdGVkLg==
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Benchmarking hashcode algorithms Roedy Green <see_website@mindprod.com.invalid> - 2014-04-26 09:49 -0700
Re: Benchmarking hashcode algorithms Marcel Müller <news.5.maazl@spamgourmet.org> - 2014-04-26 18:54 +0200
Re: Benchmarking hashcode algorithms Roedy Green <see_website@mindprod.com.invalid> - 2014-04-26 12:24 -0700
Re: Benchmarking hashcode algorithms Mike Amling <mamling@chaff.us> - 2014-05-05 11:17 -0500
Re: Benchmarking hashcode algorithms Roedy Green <see_website@mindprod.com.invalid> - 2014-05-16 16:27 -0700
Re: Benchmarking hashcode algorithms Silvio <silvio@internet.com> - 2014-05-20 17:32 +0200
Re: Benchmarking hashcode algorithms Roedy Green <see_website@mindprod.com.invalid> - 2014-05-16 16:28 -0700
csiph-web