While clicking on the link of my jsp page , the CPU usage is over 50%.I want to minimised this usage.
Lots of objects are being passed around and i feel that this will cause some problem.
Very few queries are made to the database (i.e oracle DB)
Is there any tool / command to know how many objects are created in java / jsp .
I am using STRUTS framework.
Thanks in advance.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 32767
posted
0
With recent JVMs, object creation no longer has the overhead it used to have in the early days of Java, so it's probably not that which slows down the app, but actual processing. Have you ascertained that the slowdown does not stem from the DB or some other form of I/O?
Hi Ulf,
There is hardly any data in the table that i have queried. Bout 20 records only.
The datas i am querying are folders that are present like ROOT,A,B,C,D.
The java script does the formation of the folders to be displayed dynamically as in the below
ROOT
|--- A
|--- B
The formation of this menu is as follows
I feel that there's too much done during this formation and if there's a way to optimised this ,
then i feel that CPU usage will become lower.
The number of objects is far less likely to affect performance than what it is that those objects are actually doing. I'd recommend running a code profiler.
One of the most odious afflictions that Business has inflicted on the modern English language is "pro-active". Most of the time it's simply redundantly used in place of the simple old word "active". And a good deal of the rest of the time it means "You're not overworked enough yet, so go out and find more!"
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 32767
posted
0
Assumptions about what is or isn't going to be fast frequently turn out to be incorrect. It's much better to have actual numbers on which to base decisions.
vanlalhmangaiha khiangte
Ranch Hand
Joined: Sep 11, 2006
Posts: 163
posted
0
@Tim : Went to google for javascript code profiler , got this javascript profiler will try this.
Dont know much about this , so if you suggest better tool , then will use that.
@Ulf : Will try to use that JAMon tool to check where the problem is.
Will get back to you guys if any findings are there ..
Thanks.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 32767
posted
0
Now I'm confused - when you said "CPU usage is over 50%", do you mean the client or the server? JavaScript runs on the client, so unless you're talking about creation of JavaScript objects a JavaScript profiler won't help.
Tim probably meant a Java profiler for the web app (like jamon).
vanlalhmangaiha khiangte
Ranch Hand
Joined: Sep 11, 2006
Posts: 163
posted
0
Yes on the client side. Not on the server.
So i should use only JAMon and not the javascript profiler ?
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 32767
posted
0
JAmon is a Java profiler - it doesn't know anything about JavaScript. Conversely, any JavaScript profiler is useless for Java.
But let's take a step back. Originally you wanted to profile "objects ... created in java", in other words, on the server. Now you're saying you want to profile on the client, where there's no Java code running. Are all these just guesses where the problem might be, or have you been able to rule out conclusively either the client or the server as the source of the problem?
vanlalhmangaiha khiangte
Ranch Hand
Joined: Sep 11, 2006
Posts: 163
posted
0
Hi guys,
I used the JAMon. I had put it for the action class and the jsp which i thought was taking time.
For the Action class : 31.99 ms , For the jsp : 7.5 ms (this is the average result)
What surprises me here is the CPU usage is still 50% above on the first time i access the links.
And after that it will be in the 30's zone and sometimes 20's zone and sometimes hardly above 10%.
So what to do next ?
Thanks ..
vanlalhmangaiha khiangte
Ranch Hand
Joined: Sep 11, 2006
Posts: 163
posted
0
Are all these just guesses where the problem might be, or have you been able to rule out conclusively either the client or the server as the source of the problem?
Yep.Don't know where the problem is. Trying to find out
So i still need to run the javascript profiler on my jsp page ?
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 32767
posted
0
I don't understand why you're so intent on profiling JavaScript - are you doing extremely heavy processing in JavaScript? That would be rare for a web app.
I'd start by measuring the time spent on the client, the time spent on the network, the time spent in the server code, the time spent for DB calls etc. Only then will you know what's taking up time.
steve souza
Ranch Hand
Joined: Jun 26, 2002
Posts: 851
posted
0
Having a cpu utilization of 50% isn't necessarily a bad thing. You aren't being very clear about what problem you are trying to solve.
I have no idea if it is your "problem" or not, but be careful with lots of string concatenations. I saw that in your code here. Assuming you use "printstr+=..." in your code for each cell then this could quickly cause a problem.
You are at 50% CPU usage for less than 50 milliseconds? This doesn't sound like a problem to me. Or am i missing the point?
Yes. As soon as i clicked on the link, CPU usage will be more than 50%. After that it's ok.
But as i have already stated, why this much usage when very less DB calls are made.
@steve : Lots of string concatenation are going on in the javascript and the javascript is quite complex.That's why i originally thought where the problem was.