The general approach to this is to:
- Get the time at the start of your benchmark, say at the start of
main().
- Run your code.
- Get the time at the end of your benchmark, say at the end of
main().
- Subtract the start time from the end time and convert into appropriate units.
A hint: look at System.nanoTime() or System.currentTimeMillis().