Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Advanced-java] improving performance of recursive algorithm
- From: chase@xxxxxxxxxxxxx (David Chase)
- Subject: [Advanced-java] improving performance of recursive algorithm
- Date: Fri, 22 Mar 2002 08:37:52 -0500
> i'm wondering how i can increase the performance of a recursive >algorithm..It takes data from a database and perform some tasks. It >takes quite a while to complete the tasks when dealing with a large >amount of data. The algorithm makes use of: > string concatenation > type casting > use of hashtable/Vector (necessary) > use of labels > does any of these affect the performance? It could be the database, of course. Be sure that you only create one connection, instead of logging in multiple times (that would be a big mistake, but you never know, so I mention it). Hashtable and Vector are both synchronized datastructures. Synchronization (especially on a multiprocessor) can be very expensive (figure 10-80 CPU cycles, depending on architecture, bus, clock rate, etc). Unless you need synchronization at that fine grain, you should (for performance) use HashMap and ArrayList. If you need larger-grained synchronization, use your own lock, but wrapped around several of the simpler operations. For string manipulation, be sure to do most of your work in StringBuffers. Once you are only examining them, they can be Strings. Now, of course, there's also the possibility that there's problems with your algorithm, but that is another matter. David Chase
- References:
- [Advanced-java] improving performance of recursive algorithm
- From: Sergio Luis Sardi Mergen
- [Advanced-java] improving performance of recursive algorithm
- Prev by Date: [Advanced-java] improving performance of recursive algorithm
- Next by Date: [Advanced-java] fetch url problem
- Previous by thread: [Advanced-java] improving performance of recursive algorithm
- Next by thread: [Advanced-java] improving performance of recursive algorithm
- Index(es):