• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java code optimization using Eclipse

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any way by which we can optimize our code, written in java, using Eclipse IDE ?

Or do we need some plugins to do the same ?

Thanks,
Gunjan
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You optimise code in an IDE the same way you optimise it outside the IDE: you don't.

Not quite true: You make sure to use efficient algorithms, eg bubble sort is faster than merge sort for 20 items, but merge sort is much faster over about 100 items. You avoid using + for Strings in several lines; use a StringBuilder instead. You avoid unnecessary synchronization (use ArrayList instead of Vector). You read this article by Brian Goetz which tells you what to so. You ask a bartender to move this thread to Performance.
 
Ranch Hand
Posts: 341
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are a few plugins in eclipse that evaluate your code against different parameters e.g. java coding standards etc. to tell the efficieny of code. This in turn helps you to optimize the code.An example of such plugin is AppPerfect Code Analyzer.

But, as Campbell suggested to follow the standard practices. That's the best way to write optimised code. Relying on eclipse plugins is not a good practice.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The most important steps to optimizing your code is to define what performance you need, find out where that performance isn't met, and then use a profiler to find out what the bottle neck is in the code. When you have identified the bottleneck, you can start actually optimizing it away - how you do that will actually depend on the cause of the bottleneck, and I don't think there is any plugin that can do this for you.

A good commercial profiler that also comes with Eclipse integration is JProfiler.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Campbell Ritchie:
You ask a bartender to move this thread to Performance.

I think the question has been substantially answered anyway, so I will leave it here.

 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Better yet, you design and code your application with sense, but not excessive attention to efficiency. Then you benchmark it against real-world loads and tune it. If you've coded flexibly, you then will have the ability to adjust the algorithms and re-benchmark until the cost of getting it any more efficent exceeds the amount of savings the efficiency gains will return. Which in today's world usually happens fairly quickly.

Knowing your workload is important. One of my favorite examples was a list averaging about 1200-1500 items. It was almost in perfect order, which is worst-case for heap and quicksorts, but had a couple of items in an odd place, so it was also nearly worst case for bubble sort. The optimal solution was a shellsort, which quickly popped the miscreant items into place. We used this thing several hundred times a day - on a mainframe - so the time spent tuning was well invested.

Eclipse is just a framework. There are external tuning tools that can plug into it, but it's the tools you'd want, not info about Eclipse. And most of the good ones can run with or without Eclipse.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic