This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "best performance ?" Watch "best performance ?" New topic
Author

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
Rancher

Joined: Mar 22, 2000
Posts: 12671
    
    5
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.

Bill

Java Resources at www.wbrogden.com
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 852
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 ?
 
Similar Threads
Mark Hansen - Testing SOA
Native contact list
telephone directory & collections ...
Best algorithm to find the duplicate number
How to store unique elements in List?