Simon Fraser University CMPT 295 Lab5.
Objective:
The purpose of this lab is to introduce us to the idea of benchmarking and to familiarize
ourselves with some of the tools used to benchmark code.
What is Code Benchmarking
Wikipedia says that “in computing, a benchmark is the act of running a computer program in
order to assess its relative performance, normally by running a number
...[Show More]
Simon Fraser University CMPT 295 Lab5.
Objective:
The purpose of this lab is to introduce us to the idea of benchmarking and to familiarize
ourselves with some of the tools used to benchmark code.
What is Code Benchmarking
Wikipedia says that “in computing, a benchmark is the act of running a computer program in
order to assess its relative performance, normally by running a number of standard tests and
trials against it.”
In this lab, we shall benchmark our program to assess its time performance as it is executing a
few tasks on an array of various sizes. More specifically, we shall look at how long our program
takes to …
randomize an array of various sizes, and
quicksort this array, using two different partitioning algorithms.
Part 1: Benchmarking a Loop
Login to a CSIL machine in the Linux environment, download Lab5-files.zip and
unpack it into sfuhome/CMPT295. Change directory into Lab5 where you will find the
usual makefile and a collection of source files.
Start by opening main.c in your favourite editor. The program’s main purpose is to
initialize an array of N integers, in the range [0, (N-1)/100], in a randomly permuted order.
When you build the executable and run it, it will display the time it took (in microseconds
(μs)) for the main loop to complete. This is done via the getrusage() system call,
which asks the Linux operating system how much processor time has elapsed since the
beginning of the program. Both calls to getrusage() record timing information in their
parameters start and end.
Important step: To know exactly how this timing information is processed, have a look at
the printf statement in main.c where you will find both parameters start and end
being used. To understand how they are used in this statement, first notice that they are
both of type struct rusage, then have a look at the content of this struct by either
using the man page: man getrusage, or having a look at http://man7.org/linux/manpages/man2/getrusage.2.html.
[Show Less]