• Post Reply Bookmark Topic Watch Topic
  • New Topic

Slow application  RSS feed

 
michael yue
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have a problem with slow performing standalone application. Basiccaly this application takes data from different tables and compile it into a txt files to make a report. There are quite a few sql statements to be executed and if else statements. I was sondering whether there is any way to speed up the process. There a lot of data involved sometimes from the db tables.
Should I use threading?
thanks
 
Tim West
Ranch Hand
Posts: 539
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some ideas...
If I were you I'd start by determining where the bulk of the time is being spent.
Initially I'd want to check whether it was in the DB access code or the rest of your code (unless you're already sure on this one). The way I'd do this is to create a static "monitoring" object. Immediately before each call into the database use System.currentTimeMillis() to get the current system time. After each call use the same, and send the difference to the monitoring object.
If you sum these times, you can work out what proportion of overall execution time is spent accessing the database, and you can proceed from there.
If most time is in the database, consider filtering these time calls by "call type". It might be that one of your SQL statements has to do a horrible join, or isn't selecting on a key field, but the rest of the app is working fast.
I'd try to avoid using threads because of the complexity they introduce.
Cheers,

--Tim
 
fred rosenberger
lowercase baba
Bartender
Posts: 12529
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, and correct me if i'm wrong, Threading isn't a "magic bullet" that will fix every slow application. If the (assumed) single CPU is already being pegged at near 100%, threading can actually slow things down.
Threading would only help if a) you have multiple CPUs, b) the CPU has a lot of "down time" while waiting for things like user input, disk access, data to be returned from somewhere else...
I am, by NO means, an expert on the subject, but this is my understanding of the issue.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tim West:
If I were you I'd start by determining where the bulk of the time is being spent.
Initially I'd want to check whether it was in the DB access code or the rest of your code (unless you're already sure on this one). The way I'd do this is to create a static "monitoring" object.

Or you could simply make use of a profiler.
If you find that DB access is your bottle neck, you can use IronGrid SQL to investigate further.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Jamon toolkit is handy for accumulating timing statistics.
Bill
 
Leandro Oliveira
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try to use a buffer, don't write short pices of data to the file... it really helps!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!