//======================================================= file = rate.c ===== //= Program to convert to rate values = //=========================================================================== //= Notes: = //= 1) Input from input file "in.dat" to stdin (see example below) = //= * Input is two columns of reals with no commas = //= * No comments are allowed in the input file = //= 2) The BLOCK_SIZE is the number of tuples to block together = //= 3) The CLK_TYPE is for the output to be delta or cumulative time = //= 4) Output is to stdout = //=-------------------------------------------------------------------------= //= Example "in.dat" file: = //= = //= 0.01 100 = //= 0.02 125 = //= 0.01 80 = //= 0.03 90 = //= 0.01 100 = //= 0.02 200 = //= 0.01 100 = //=-------------------------------------------------------------------------= //= Example output (for above "in.dat", BLOCK_SIZE = 2, and CLK_TYPE = 2) = //= = //= & --------------------------------------------- rate.c ----- & = //= 0.030000 60000.000000 = //= 0.070000 34000.000000 = //= 0.100000 80000.000000 = //= & ---------------------------------------------------------- & = //=-------------------------------------------------------------------------= //= Build: bcc32 rate.c = //=-------------------------------------------------------------------------= //= Execute: rate < in.dat = //=-------------------------------------------------------------------------= //= Author: Kenneth J. Christensen = //= University of South Florida = //= WWW: http://www.csee.usf.edu/~christen = //= Email: christen@csee.usf.edu = //=-------------------------------------------------------------------------= //= History: KJC (05/14/02) - Genesis = //=========================================================================== //----- Include files ------------------------------------------------------- #include // Needed for printf() and feof() #include // Needed for exit() and ato*() #include // Needed for strcmp() //----- Defines ------------------------------------------------------------- #define BLOCK_SIZE 2 // Block size for computing rates #define CLK_TYPE 2 // Output is 1 = delta, 2 = cumul time //=========================================================================== //= Main program = //=========================================================================== void main(void) { double time_stamp; // Delta time stamp of a tuple double num_bytes; // Number of bytes of a tuple double sum_time; // Running sum of time double cumul_time; // Running cumulative time double sum_bytes; // Running sum of bytes double block_mean; // Compute block mean char instring1[1024]; // Input string #1 char instring2[1024]; // Input string #2 int i; // Loop counter // Output a banner printf("& --------------------------------------------- rate.c ----- & \n"); // Compute rates until end-of-file cumul_time = 0.0; while(1) { // Compute a rate for block_size values sum_time = 0.0; sum_bytes = 0; for (i=0; i