#include #include #include #include #include #include #include #include "nano_time.h" //#define TEN_GB_IN_BYTES 10737418240 //#define block_size 4096 #define READ 1 #define WRITE 2 #define NANOSECONDS_IN_SECOND 1000000000 #define BYTES_IN_GB (1024*1024*1024) int main(int argc, char** argv){ char* op = argv[1]; char* bs = argv[2]; char* fs = argv[3]; int optype = atoi(op); uint64_t filesize = strtoul(fs, 0, 10); uint64_t block_size = atoi(bs); char* big_buffer = (char*)malloc(filesize); char* buffer = (char*)malloc(block_size); uint64_t i, t_ops = 0; uint64_t begin_time, end_time; memset((void*)big_buffer, 0, filesize); memset((void*)buffer, 0, block_size); //printf("Memset done!"); // sleep(5); // printf("Done sleeping\n"); // sleep(5); begin_time = nano_time(); // for(i = 0; i < TEN_GB_IN_BYTES/block_size; i++){ for(i = 0; i< filesize; i+= block_size){ if (optype == READ) { memcpy(buffer, &big_buffer[i], block_size); t_ops += buffer[0]; } else if (optype == WRITE) { memcpy(&big_buffer[i], buffer, block_size); // Arbitrary operation. t_ops += big_buffer[i]; } } end_time = nano_time(); // Run the same above loop again // To see the effects of warm data printf("\t%.2f\n", (double)filesize/(double)((end_time-begin_time)) * NANOSECONDS_IN_SECOND / BYTES_IN_GB); //free both the buffers }