• Post Reply Bookmark Topic Watch Topic
  • New Topic

byte comparison and see efficiency of each operation  RSS feed

 
sai rama krishna
Ranch Hand
Posts: 536
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How to do byte comparison and see efficiency of each operation as below one with using string and other using string builder.



I am using eclipse IDE. Is there is a plugin i can directly use to do it.
 
Chris Barrett
Bartender
Posts: 321
24
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sai,

As your second concatenating loop of immutable Strings is going to create a bunch of immutable Strings in the String Pool, any perceived question of time efficiency would be somewhat irrelevant in light of the much larger memory usage inefficiency your question is creating.

Cheers!
Chris
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chris Barrett wrote:As your second concatenating loop of immutable Strings is going to create a bunch of immutable Strings in the String Pool

No it's not. It will create a bunch of Strings, but not in the String pool. The created Strings will be more or less immediately available for garbage collection.
 
Paul Clapham
Sheriff
Posts: 22834
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
However Chris does correctly raise the question of what does "efficiency" mean in this context.
 
sai rama krishna
Ranch Hand
Posts: 536
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to check and see generated byte code and compare. I see drgarbage.com website has some plugin with eclipse but not sure how to use it.
http://www.drgarbage.com/
Are there are any other tools, techniques to analyse efficient operation with or without eclipse. please advise
 
Paul Clapham
Sheriff
Posts: 22834
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's the "javap" command which displays the byte-code for a compiled class. It looks like you've already found a plugin, so go ahead and install it. If you don't know how to install an Eclipse plugin, my guess is that the google keywords install eclipse plugin would lead you to instructions pretty quickly.

Do you have a strategy for extracting "efficiency" measurements from byte-code?

 
Paul Clapham
Sheriff
Posts: 22834
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I just clicked on a few links on that site and found their explanation of how to install their plugins into Eclipse: How to download and install Dr. Garbage Plugins, which looks pretty simple to me.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a beginning topic. Moving discussion.
 
sai rama krishna
Ranch Hand
Posts: 536
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i was able to install the plugin. I was not sure on how to use it or invoke it. Plugin supposed to be invoked while creating the .class file?

Do you have a strategy for extracting "efficiency" measurements from byte-code?

i do not know above strategy as well how to do it. please advise
 
Paul Clapham
Sheriff
Posts: 22834
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sai rama krishna wrote:i do not know above strategy as well how to do it. please advise


It was your idea to look at the byte-code, wasn't it? That must have been based on some reasoning that the byte-code would tell you something that the source code doesn't. So, what was that reasoning?
 
sai rama krishna
Ranch Hand
Posts: 536
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wonder if there is a way to time the two different methods i posted to see the efficiency of each method say using drgarbage or any other tool or application. Please advise
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sai rama krishna wrote:I wonder if there is a way to time the two different methods i posted to see the efficiency of each method say using drgarbage or any other tool or application. Please advise

What do you mean by "efficiency"? that is where folks are having problems understanding how to help you.

Are you simply interested in the TIME it takes to run each version? Or are you interested in how much MEMORY each version takes? or both?

The simplest way to do it is to get the system time before you start, run it a million times (or whatever) and get the new system time, then compute the difference. Note that getting the system time can be tricky, as the resolution may not be precise enough.

But another question for you is...Does it really matter? If this is just academic, ok. But if you are trying to optimize to get the best possible time, then this is probably not the place you should be looking to optimize in any case.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you run that loop more than about 10000 times, you won't need a profiler. You need a watch with a second hand
 
sai rama krishna
Ranch Hand
Posts: 536
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is drgarbage is a profiler tool? Are there are any other similar profiller tools which i can use without using a stop watch say for execution of loop say 1 time( may be value in mini or micro seconds but still i want to track it..all this is for academic interst only I am asking). Please advise
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!