#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <math.h>
#include "report.h"
Defines | |
| #define | R 5 |
| Number of rows to compute. | |
| #define | T 30 |
| For each row, the number of trials to execute. | |
Functions | |
| char * | buildRow (long n, long times[R][T]) |
| Build a row for the output by computing average and stdev after discarding the lowest and highest results. | |
| void | buildTable (long times[R][T]) |
| long | diffNanoTimer (struct timespec *before, struct timespec *after) |
| Compute the difference between two time values in usecs. | |
| int | main (int argc, char **argv) |
| Compute the addition of numbers in range 1,000,000 to 5,000,000 for a fixed number of trials. | |
Variables | |
| long | MStimes [R][T] |
| Raw information regarding millisecond results. | |
| long | NStimes [R][T] |
| Raw information regarding nanosecond results. | |
| timespec | before |
| Time (in nanoseconds) after process completes. | |
| timespec | after |
| Time (in nanoseconds) after process completes. | |
| timeval | beforeV |
| Time before process starts. | |
| timeval | afterV |
| Time after process completes. | |
| char | buf [1024] |
| More than enough scratch room. | |
Must be compiled with the -lrt libraries.
| #define R 5 |
Number of rows to compute.
| #define T 30 |
For each row, the number of trials to execute.
| char* buildRow | ( | long | n, | |
| long | times[R][T] | |||
| ) |
Build a row for the output by computing average and stdev after discarding the lowest and highest results.
| void buildTable | ( | long | times[R][T] | ) |
| long diffNanoTimer | ( | struct timespec * | before, | |
| struct timespec * | after | |||
| ) |
Compute the difference between two time values in usecs.
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Compute the addition of numbers in range 1,000,000 to 5,000,000 for a fixed number of trials.
Using this information we create a histogram of sorts and output the reults.
| struct timespec after |
Time (in nanoseconds) after process completes.
| struct timeval afterV |
Time after process completes.
| struct timespec before |
Time (in nanoseconds) after process completes.
| struct timeval beforeV |
Time before process starts.
| char buf[1024] |
More than enough scratch room.
| long MStimes[R][T] |
Raw information regarding millisecond results.
| long NStimes[R][T] |
Raw information regarding nanosecond results.
Algorithm Development Kit 1.0