cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Ziegeler" <cziege...@s-und-n.de>
Subject RE: [RT]: Calculating the cache key
Date Mon, 27 May 2002 06:07:02 GMT

Geoff Howard wrote:
> >
> > To come to a conlusion I did a simple performance test:
> > - Creating 10000 random keys (strings) where each character is a value
> > between 0 and 9
> > - Hashing the 10000 values
> > - Putting the strings into the cache (a HashMap)
> > - Putting the Hashed values into another cache (a HashMap)
> > - Searching for all values in the string cache
> I guess you mean for each value (in a loop)?

Exactly.

>
> > - Searching for all values in the hashed cache (this requires
> > of course
> > rehashing the values)
> >
> > And this is the result:
> > Start key generation
> > Created 10000 strings with average length 169
> OK,
> > Start hashing
> > Hashed: 120 ms
> 120 for all 10,000 -> The hashing function takes .012 ms per call
> on average
Yes.

>
> > Creating cache with Strings
> > Created: 60 ms
> 60 ms for all 10,000 -> .006 ms on average
Yes, this means all 10,000 strings are put into the hash map

> > Creating cache with longs
> > Created: 30 ms
> same, .003 ms for longs (faster)
Yes.

> > Testing strings
> > Strings: 10 ms
> Object = mapWithStrings.get(KeyString) -> 10 ms for all 10000? -> .001 ms
> per lookup average? (wow)
Yupp.

> > Testing hashed strings
> > Hashed strings: 131 ms
> Object = mapWithHashes.get(hashCreate(KeyString)) -> 131 ms for
> all -> .0131
> ms per lookup average.

Yes.

>
> >
> > So, looking up the hashed information is slower as the values
> > have to be
> > rehashed. But
> > putting strings into the cache is slower.
> But putting strings in only takes twice the time -- taking them out is ten
> times faster and happens more often (right?)

Should be, yes.

>
> > From the test above it seems that using strings is still a
> > little bit faster
> > than
> > using hashed values.
> > Or did I oversee something?
> I had been assuming that if the keys were not objects (strings)
> but integers
> that there could be a better datastructure than HashMap.  I
> haven't had much
> time to think about it today but will tonight.  Any ideas?

In general this is right, but not for the cocoon caching. The tests
I did are for one part of the compound key. I wanted to know if
it is faster to use a string or a hashed value for this one part.
The complete cache key is constructed from several parts, so
this can never be a simple number.

Carsten


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message