Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to know how many objects are created

 
vanlalhmangaiha khiangte
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

You could start by running something like JAMON: http://jamonapi.sourceforge.net/
 
vanlalhmangaiha khiangte
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks in advance.



>
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18014
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes on the client side. Not on the server.
So i should use only JAMon and not the javascript profiler ?
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
vanlalhmangaiha khiangte
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.






 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic