aspose file tools*
The moose likes Performance and the fly likes How to know how many objects are created Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "How to know how many objects are created " Watch "How to know how many objects are created " New topic
Author

How to know how many objects are created

vanlalhmangaiha khiangte
Ranch Hand

Joined: Sep 11, 2006
Posts: 170
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: 42612
    
  65
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/


Ping & DNS - my free Android networking tools app
vanlalhmangaiha khiangte
Ranch Hand

Joined: Sep 11, 2006
Posts: 170
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

Joined: Jun 25, 2001
Posts: 16250
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42612
    
  65
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: 170
@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: 42612
    
  65
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: 170
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: 42612
    
  65
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: 170
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: 170
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: 42612
    
  65
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: 861
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.



http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30938
    
158

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?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
vanlalhmangaiha khiangte
Ranch Hand

Joined: Sep 11, 2006
Posts: 170

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.






 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to know how many objects are created