Chapter1/tester.c File Reference

Driver for testing allocation/deallocation mechanisms. Allocate REALLY large number of allocations and then time the cost to deallocate just one of these (the last one). More...

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include "report.h"

Defines

#define FREEERROR   0
 Invalid Strategy.
#define FREEUP   1
 Strategy to deallocate in order.
#define FREEDOWN   2
 Strategy to deallocate in reverse order.
#define FREESCATTERED   3
 Strategy to deallocate in random order.

Functions

void generateTable (int strategy)
 Generate a table of memory and release with given strategy.
int main (int argc, char **argv)

Variables

static char * types [4] = {"", "UP", "DOWN", "SCATTERED" }
 Known allocation types (1-3 are valid).
static struct timeval before
 Time before process starts.
static struct timeval after
 Time after process completes.
int n
 value for number of elements in a trial suite.
int lowN
 Low value for number of elements in trial suite.
int highN
 High value for number of elements in trial suite.


Detailed Description

Driver for testing allocation/deallocation mechanisms. Allocate REALLY large number of allocations and then time the cost to deallocate just one of these (the last one).

Note that each trial must be a separate execution since we don't want to mistakenly compare (i) what happens when you allocate memory for the first time; with (ii) what happens when you allocate memory where some previously allocated memory has been free'd.

Author:
George Heineman
Date:
6/15/08

Define Documentation

#define FREEDOWN   2

Strategy to deallocate in reverse order.

#define FREEERROR   0

Invalid Strategy.

#define FREESCATTERED   3

Strategy to deallocate in random order.

#define FREEUP   1

Strategy to deallocate in order.


Function Documentation

void generateTable ( int  strategy  ) 

Generate a table of memory and release with given strategy.

Parameters:
strategy UP, DOWN, or SCATTERED as the strategy to use.

int main ( int  argc,
char **  argv 
)


Variable Documentation

struct timeval after [static]

Time after process completes.

struct timeval before [static]

Time before process starts.

int highN

High value for number of elements in trial suite.

int lowN

Low value for number of elements in trial suite.

int n

value for number of elements in a trial suite.

char* types[4] = {"", "UP", "DOWN", "SCATTERED" } [static]

Known allocation types (1-3 are valid).

Algorithm Development Kit 1.0