# Assignment 1: Benchmarks

**Due:** 5:00pm, Thu 24 Jan.
**Value:** 30 pts.
Submit to Moodle.

Write a report comparing the performance of three
computers: A Linux lab computer (they're all identical),
`grendel`, and `ozark`.
Your report should be submitted as an ASCII text file
(created with a program such the lab computers' text editor,
*gedit*). Your report should have three sections:

Start with your numerical results. In particular, you should include ten numbers:

`T`_{prime,lab}: The raw time for a Linux lab computer to execute the prime-testing program described below.`T`_{gauss,lab}: The raw time for a Linux lab computer to execute the Gaussian integral program described below.`T`_{prime,grendel}: The raw time for`grendel`to execute the prime-testing program described below.`T`_{gauss,grendel}: The raw time for`grendel`to execute the Gaussian integral program described below.`T`_{prime,ozark}: The raw time for`ozark`to execute the prime-testing program described below.`T`_{gauss,ozark}: The raw time for`ozark`to execute the Gaussian integral program described below.`T`_{prime,grendel}/`T`_{prime,lab}`T`_{prime,ozark}/`T`_{prime,lab}`T`_{gauss,grendel}/`T`_{gauss,lab}`T`_{gauss,ozark}/`T`_{gauss,lab}

This should be followed by a precise description of your procedure for obtaining these measurements. Include the exact terminal commands you executed to obtain each.

Finally, in an appendix, include the actual code you used for implementing the prime-testing and Gaussian integral benchmarks.

Except for the appendix, the report should be written in a professional, coherent style. Your grade will be based primarily on the professionalism and style of your writing and coding, and only secondarily on the accuracy of your conclusions. The assignment intentionally leaves unspecified exactly which technique to use for your measurements, as part of our goal is to compare different measurement techniques.

Assume that your classmates will read your completed report. Following completion, we'll compare the results and techniques by students.

## Prime testing

For a value of `n`
(it is up to you to choose how to select `n`),
we determine whether `n` is prime
using the following technique:

d← 2

whiled² <n:

ifnmodd= 0:

returnfalse

d←d+ 1

returntrue

## Gaussian integral

For a value of `n`,
(it is up to you to choose how to select `n`),
we approximate the integral of
`f`(`x`) = `e`^{−x² / 2} for between −2 and 2
using the following adaptation of Simpson's rule.
(When `n` is large, the answer is close to 2.392576.)

sum←f(−2) +f(2)

delta← 4 /n

forifrom1ton− 1,inclusive:

sum←sum+ 3 ⋅f(−2 +i⋅delta)

returndelta⋅sum/ 3

To compute `e`^{y}, you'll want to use the built-in
`exp`

function, which will be included in the same
library including `sin`

and `log`

.

(The reason behind the selection of these two benchmark programs is that the first concentrates on integer arithmetic heavily while the second uses floating-point arithmetic, so in fact the two programs are testing different parts of the processor. You'll likely arrive at similar speed ratios for each benchmark, though.)

## Accessing `grendel` and `ozark`

You cannot physically access `grendel` and
`ozark`, since they are locked in the server closet.
(Our file server is `grendel`, while `ozark`
serves as the Web server.)

However, you can use `ssh` to
execute terminal commands on them: From a Linux lab terminal, you can
execute “`ssh grendel`

” and type your password
when prompted; any subsequent commands you execute in that
terminal will be sent for
`grendel` to execute.

You can do similarly with
`ozark`, but your home directory won't have the same
files as on the lab computers or `grendel`.
However, you may copy any file from the lab computer into your
home directory's `www` subdirectory, and it will be
visible in the `www` subdirectory on `ozark`.