

For example, look at Java's sort() method above. If you did not use any submethods, then Total Time will be equal to Self Time. The Self Time is the time spent only within the specified method, whereas the Total Time will include the time used on any submethod calls. In the VisualVM profiler, you should always look at the Total Time for each of your sorting methods. Alternatively, you can have a dedicated Heap class, with seperate methods to insert, build-max-heap, and delete.

For example, the lecture notes contain the heap sort within one method. Beyond that, it is up to you whether you put everything in one function, or have many submethods. Read the Submethods section below for explanation.įor Q1-Q4 (and bonus), you have to make sure you use the method signatures shown in the assignment. Look at the TOTAL TIME for your methods.
#VISUALVM 1.3.9 PLUS#
At the bottom of VisualVM, you can search for "sort", which will pull up your Sorting class methods plus Java's sort() method.Most of these are warnings you can ignore, as long as you see the results in VisualVM. At this point you should see a bunch of stuff happen, and after a while your program terminates and VisualVM will show the time spent on each method in your classes.make sure you already compiled your program.įor example: java -agentpath.\lib,5140 A4Q5 Run your program as usual, but with the copied string as a flag. In terminal/cmd, navigate to your compiled Java files.You have to do this first, before you run your Java program. Leave this screen open, as it's waiting for you to run your Java program. Once it's done, you will end up with a screen that says "Connecting to VM.".Make sure you allow the firewall connection. If it's your first time, it was ask to calibrate, which you should agree to.

Clear the second box, since we want Java's sorting algorithm to be included (it's part of java.*). The first one is pre-filled with red text which you should replace with your class names (eg. This will show all three parts of the dialogue (shown below).
