0% found this document useful (0 votes)
15 views7 pages

Benchmarking in Java

The document discusses the importance of benchmarking algorithms in Java, emphasizing the need for empirical performance comparisons and the influence of various factors on running time. It explains how time is represented in Java using milliseconds since the Unix Epoch and provides methods for obtaining current time in both milliseconds and nanoseconds. Additionally, it includes references for further reading on Java's System class and benchmarking issues.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views7 pages

Benchmarking in Java

The document discusses the importance of benchmarking algorithms in Java, emphasizing the need for empirical performance comparisons and the influence of various factors on running time. It explains how time is represented in Java using milliseconds since the Unix Epoch and provides methods for obtaining current time in both milliseconds and nanoseconds. Additionally, it includes references for further reading on Java's System class and benchmarking issues.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Benchmarking Algorithms in Java

Dr Patrick Mannion
[Link]@[Link]

Dr Patrick Mannion, Dept of Computer Science & Applied Physics 1


Overview
• Motivation for benchmarking
• Time in Java
• Benchmarking a single run
• Benchmarking multiple statistical runs

Dr Patrick Mannion, Dept of Computer Science & Applied Physics 2


Motivation for benchmarking
• Benchmarking or a posteriori analysis is an empirical method to
compare the relative performance of algorithm implementations
• Experimental (e.g. running time) data may be used to validate
theoretical or a priori analysis of algorithms
• Various hardware and software factors such system architecture, CPU
design, choice of Operating System, background processes, energy
saving and performance enhancing technologies etc. can affect
running time
• Therefore it is prudent to conduct multiple statistical runs using the
same experimental setup, to ensure that your set of benchmarks are
representative of the performance expected by an “average” user
Dr Patrick Mannion, Dept of Computer Science & Applied Physics 3
Time in Java
• Dates and times in Java are represented as the number of
milliseconds that have elapsed since midnight on January 1 1970 (the
“Unix Epoch”)
• 1 second = 1,000 milliseconds = 1,000,000,000 nanoseconds
• Each millisecond since the Unix Epoch has a specific timestamp
• Stored using the long type in Java (i.e. a timestamp is a large integer)
• e.g. long currentTime = [Link](); // current time in millisec
• [Link]() gives a higher resolution
• e.g. long currentTime = [Link](); // current time in nanoseconds

Dr Patrick Mannion, Dept of Computer Science & Applied Physics 4


Benchmarking a single run

Dr Patrick Mannion, Dept of Computer Science & Applied Physics 5


Benchmarking multiple statistical runs

Dr Patrick Mannion, Dept of Computer Science & Applied Physics 6


Useful references
• Java 8 System class documentation:
[Link]
• Java Date and Time overview:
[Link]

• Discussion of benchmarking issues in Java (advanced material):


[Link]

Dr Patrick Mannion, Dept of Computer Science & Applied Physics 7

You might also like