Do you have any tips for effective profiling using Netbeans?
The profiler is quite nice and powerful. I've used it to find problems in some of my Eclipse RCP client applications. However, I get the feeling that I could get some more value out of it.
Normally I set it to profile either all my classes (starting with xxx.mydomain) using an inclusive filter, or I use an exclude filter to remove all org.eclipse classes. This helps keep the overhead down. After running the section of code I am interested, I take a snapshot. I analyze for hotspots and then change the code, repeat the profiling, take another snapshot and compare again.
Any other suggestions or tips on how to get the most out of the profiler with client applications?
The JavaOne lab exercises are available online for free, you should be able to get some good tips there.
http://developers.sun.com/learning/javaoneonline/j1labs2008.jsp?track=1&yr=2008
Specifically this link is interesting from the Java One Lab
http://developers.sun.com/learning/javaoneonline/j1lab.jsp?lab=LAB-8430&yr=2008&track=1
Related
in my project I wrote a java-agent library, which i want to profile. This question was already asked in 2013 here. So, I tried following the suggestion, using sprof, which failed due to this problem. I have also tried oprofile, however I am still not able to identify the bottlenecks of my application from its output.
So, my question is, what are the other suitable profilers for java native libraries? Does anyone have expirience in this kind of task?
You may find useful VTune Amplifier which is a profiler supportingĀ Java code analysis. You will be able to see the hotspots in your Java code and the performance metrics distributed through your java source file. What's really valuable is that VTune Amplifier shows the accurate stacks for pure Java code and Java/C++ mixed mode code. Please ask if you have questions.
First of all you should choose "Hotspots and stacks" while you're configuring analysis. See screenshot below. When collection is done that you should switch to the "Top-down Tree" tab in VTune UI. More info about the "Top-down Tree" tab is here.
Try to use "Hotspots, call count and stacks" to get call counts.
I just have installed intelliJ IDEA 15 but it's somehow laggy and uses a lot of RAM. Sometimes more than 1GB on my 4GB-RAM laptop.
Are previous versions of intelliJ better in performance?
How can i make it faster?
And another problem I have is with Auto completion and correction.
Where are these two settings? Cause it doesn't seem as good as Eclipse.
Usually if you have performance problems, the first place I would advice is to look at the plugins which are activated, perhaps you don't need those plugins.
File -> Settings -> Plugins
Secondly, intelliJ indexes your files so that all its wonderful searches and short cuts, so, if you have a huge project, the first indexing will take some time.
For tips on auto-completion etc. Take a look at the official docs.
https://www.jetbrains.com/idea/help/auto-completing-code.html
Extra Tips
When I started using IntelliJ, I found lot of videos on youtube about how to use it, these tips have helped me get more productive. I don't want to start a debate on Eclipse vs IntelliJ vs Netbeans etc., but each IDE has a vision and a way it was intended to be used, so moving from one to another does need a ramp up time.
I am completely new to code analysis. I want to know if there is an easy to use analysis tool or plugin for eclipse that will analyze my java code.
The problem is my java swing program is taking too much time, because I manually did many graphical programming.
For example, I have a list of images that are displayed dynamically, on top of each other (like layers in Photoshop). Each of them will respond to user movements, so I have to update the images each time the user triggers a change.
However, after adding some features (such as ColorOP, RescaleOP, etc.), the program started to lag. Now, I want to know which part of the code is inefficient and taking too much time, so that I can find better alternatives. Is there a tool for such purpose?
Visual Performance Analysier is an open source tool from IBM, which can visualize performance profiling of Java program well.
You need to use a Java profiler, I generally prefer YourKit.
I'm looking for a tool that can graph method calls over time for a java app. Perhaps a profiler or other log parsing tool?
I know I can write something in python and I'll work towards doing this. I was just hoping not to reinvent the wheel.
edit:
What I ended up doing was writing some python to parse my logs and take snapshots at 5 second intervals. Then I used google docs and a spreadsheet to visualize my data with a chart that had 2 columns of data: time and frequency. Google docs was super useful. Use the "move chart to own sheet" for a nice fullsize view. I'll post my python when I clean it up a bit.
here is the output graph from the method I specify in my comment
Check out JProfiler. I wouldn't suggesting writing your own tool, this is a space with lots of players already....unless you're really looking for something to do. :-)
you can also check the NetBeans profiler, that's quite straight forward if you application a standard Java code (I mean, it's a bit more complicated with projects deployed in Glassfish for instance)
(from Google Image from Dr. Dobbs)
EDIT: sorry, after another look at your question, it's not exactly what you were looking for, but it might be interesting anyway
YourKit Java Profiler is probably the most powerful Java profiler out there. It is not free but not unreasonably expensive either. If it doesn't have the feature you are looking for, I kinda doubt any application would.
VisualVM is a visual tool integrating several commandline JDK tools and lightweight profiling capabilities. Designed for both production and development time use, it further enhances the capability of monitoring and performance analysis for the Java SE platform.
I have just created a mid-sized web-application using Java, a custom MVC framework, javascript. My code will be reviewed before it's put in the productions servers (internal use).
The primary objective of building this app was to solve a small problem for internal use and understand the custom made MVC framework used by my employer. So, my app has gone through MANY iterations, feature changes and additions.
So, bottom line, the code is very very dirty and this is my first "product level" Java app.
What are your suggestions, what are some basic checks/refractoring I should do before the code review?
I am thinking about:
Java best practices (conventions)
Make the code simple to understand for the developer who will maintain it. (won't be me)
I noticed, I have created some unnecessary objects and used hashmaps/arraylists where could have easily used some other Data structure and achieved the solution. So, is that worth changing?
Update
Your Code Sucks and I Hate You: The Social Dynamics of Code Reviews
If you did not already, (assuming you use an IDE like eclipse)
get plugins checkstyle and findbugs
go through their configuration and tune to your style
run them on your code
resolve all issues reported
you can also tune the compiler warning setting of eclipse itself and possibly make them more strict in what is reported.
Look at code structure:
get plugin jdepend
investigate your package structure
Code against interfaces (Map, List, Set) instead of implementation classes (HashMap, ArrayList, TreeSet)
Complete your Javadoc and make check it is up to date after all refactorings.
Add JUnit tests; if you have no time left to test the whole application, at least create a test for every bug you find and solve from now on. This helps "growing" a test set as you go.
Next time design and build your application with the end goal in sight. Always assume that the next guy having to maintain your code will know how to find you :-)
Unit tests, and they should be automated as part of your build. You should already have these, but if not, do it now. It will definitely make the refactoring easier, as well improving your general confidence in the code (and the guy who will be maintaining it).
Logging.
One of the more overlooked things is the importance of logging. You need to have a decent logging methodology put in place. Even though this is an internal app, make sure that the basic logs can help regular users find issues and provide more detailed logging so that you (the developer) would know where to go.
Comment your code, explain why it's doing what it's doing and what assumptions have been made.
Try to reduce the amount of mutating state.
Try to remove any singletons you may have.