jQuery in Action, 3rd edition
The moose likes Performance and the fly likes best performance ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "best performance ?" Watch "best performance ?" New topic

best performance ?

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
Assume I have a txt file containing ten millions phone number, record unsorted and duplicate, Now I want

1. list top 20 duplicate phone numbers
2. sorted it
3. list duplicate frequency, like one phone number has 200 duplicate.

Which way has best performance? Database is not in the option list.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
1. devise a way to turn the text of a phone number into a Java primitive, probably a long,
2. scan list adding the derived longs to a long[] array
3. sort the array

the remainder should be obvious.

steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 862
If it is in a file already you may not need to use java. You could also consider using unix utilities to sort and check for dupes.

http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
I agree. Here's the link: http://aspose.com/file-tools
subject: best performance ?
It's not a secret anymore!