#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include "unit.h"
#include <time.h>
#include "collection.h"
Go to the source code of this file.
Definition at line 37 of file main.cpp.
References c, UnitCollection::createIterator(), createUnit(), UnitCollection::empty(), UnitCollection::FreeUnusedNodes(), i, Iteration(), Unit::Kill(), UnitCollection::UnitIterator::notDone(), UnitCollection::prepend(), rnd(), and SIZE.
40 srand( time( NULL ) );
44 for (
int i = 0;
i <
SIZE; ++
i)
46 seconds = time( NULL );
47 for (
int i = 0;
i < (SIZE/2); ++
i)
49 seconds = time( NULL )-seconds;
50 printf(
"constructed list of size : %d in %d seconds using prepend\n", SIZE/2, seconds );
51 printf(
"Randomnly inserting %d \n", SIZE/2 );
53 seconds = time( NULL );
57 if (rnd < RAND_MAX/200) {
58 iter.postinsert( u[ii] );
60 }
else if (rnd < RAND_MAX/100) {
61 iter.preinsert( u[ii] );
65 seconds = time( NULL )-seconds;
66 printf(
".... took %d seconds \n", seconds );
67 for (
int i = 0; i < SIZE/32; ++i)
68 if (rand() < RAND_MAX/20)
70 printf(
"randomly killed SIZE/32 to start off with \n" );
72 printf(
"beginning unitCollection removal/advance operations\n" );
73 seconds = time( NULL );
76 while ( !c->
empty() ) {
86 seconds = time( NULL )-seconds;
87 printf(
"operations took %d seconds \n", seconds );
88 levels = levels/passes;
89 printf(
"Average number of concurrent iterators %d\n", levels );
90 printf(
"verifying destruction of units\n" );
91 for (
unsigned int i = 0; i <
SIZE; i++) {
92 if (u[i]->zapped != u[i]->killed)
93 printf(
"Unit at %d is zapped %d killed %d\n", i, u[i]->zapped, u[i]->killed );
100 printf(
"size of list is verified at %d : %d killed \n", size, SIZE-size );
102 printf(
"completed\n" );