/* * Copyright © 1998 Spizella Software * All rights reserved. * * Programmer: Robb Matzke * Tuesday, August 25, 1998 */ #include #include #include #include #include /*for performance monitoring*/ #define NOTIFY_INTERVAL 2 /*seconds*/ #define TIME_LIMIT 60 /*seconds*/ #define CH_SIZE 8192*8 /*approx chunk size in bytes*/ typedef struct { double percent; size_t lo, hi; size_t nhits; } quant_t; #if 1 /* Typical VBT sizes */ static quant_t quant_g[] = { {10.00, 1, 5}, {89.00, 6, 20}, { 0.90, 21, 100}, { 0.09, 101, 1000}, { 0.01, 1001, 10000}, }; #elif 0 /* Sizes for testing */ static quant_t quant_g[] = { {10.0, 1, 5}, {80.0, 6, 15}, {10.0, 16, 20}, }; #elif 0 /* Larger I/O */ static quant_t quant_g[] = { {10.0, 1, 1000}, {80.0, 1001, 5000}, {10.0, 5001, 10000}, }; #else /* All same size */ static quant_t quant_g[] = { {100.0, 1000, 1000} }; #endif static volatile sig_atomic_t alarm_g = 0; static volatile sig_atomic_t abort_g = 0; /*------------------------------------------------------------------------- * Function: catch_alarm * * Purpose: Increments the global `alarm_g' and resets the alarm for * another few seconds. * * Return: void * * Programmer: Robb Matzke * Wednesday, August 26, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static void catch_alarm(int signum) { static int ncalls=0; ncalls++; if (0==ncalls % NOTIFY_INTERVAL) { alarm_g++; } if (ncalls>=TIME_LIMIT) { abort_g=1; } alarm(1); } /*------------------------------------------------------------------------- * Function: rand_nelmts * * Purpose: Returns a the length of a 1-d array according to the * probabilities described above. * * Return: Success: Number of elements * * Failure: never fails * * Programmer: Robb Matzke * Thursday, August 20, 1998 * * Modifications: * *------------------------------------------------------------------------- */ static size_t rand_nelmts(void) { double p = (rand() % 1000000)/1000000.0; double total = 0.0; size_t size, i; for (i=0; i