Skip to main content

Generating auxiliary objects

2 replies [Last post]
ateslin
Offline
Joined: 2005-11-04
Points: 0

Hi,

I am trying to test HashMap collection. In order to do this I need to create key-value pairs to fill the collection. For keys i thought to create strings that must be unique and for values i can either use the same strings or get some random number and cast it to Integer object.

I can not, however, think of a method that will quickly generate unique strings by say using a 'for' loop.

Does anyone has an idea or a simple technique?

Thank you in advance.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ateslin
Offline
Joined: 2005-11-04
Points: 0

Thank you Tom,

Yes, i am trying to measure the performance. Never thought about of creating the text file. It seems that it is an easiest option. I will try that.

Thanks

tmarble
Offline
Joined: 2003-08-22
Points: 0

It depends on what you are trying to measure: functionality or performance.

If you are interested in measuring performance I'd like to encourage you to develop a set of keys and values that you use consistently for performance testing. In other words, generate a text file with a "key TAB value" per line and then reuse the same one every time.

Also the standard cautions about microbenchmarks apply:
http://java.sun.com/performance/reference/whitepapers/tuning.html#sectio...

HTH,

--Tom