int main() { //Part 1. Evaluating Hash Functions int bloomsize = 100; int x; bloom_filter_t bloomfilter; bloom_init(&bloomfilter, bloomsize); printf ("Hash1: %i %i %i %i %i %i\n",hash1(&bloomfilter, 0),hash1(&bloomfilter, 1), hash1(&bloomfilter, 2),hash1(&bloomfilter, 3),hash1(&bloomfilter, 13), hash1(&bloomfilter, 97)); printf ("Hash2: %i %i %i %i %i %i\n",hash2(&bloomfilter, 0),hash2(&bloomfilter, 1), hash2(&bloomfilter, 2),hash2(&bloomfilter, 3),hash2(&bloomfilter, 13), hash2(&bloomfilter, 97)); bloom_destroy(&bloomfilter); //Part 2: printf("\nDoing Smoke Test.\n"); bloomsize = 1000; bloom_init(&bloomfilter, bloomsize); for (x= 0; x< 70; x++) { bloom_add(&bloomfilter, x); } int totalbits = 0; for (x = 0; x< bloomsize; x++) { totalbits += get_bit(&bloomfilter, x); } printf("Total bits set: %i\n",totalbits); bloom_destroy(&bloomfilter); //Part 3 printf("\nDoing N_HASHES Test.\n"); int array1[100]; int array2[100]; gen_rand(array1, 100, 1000000); gen_rand(array2, 100, 1000000); run_test3(array1, array2, 100); }
int main(int argc, char* argv[]) { // Simulation configuration int num_of_clients = 50; // Indexing int i,j,n,l; // Temporary Logging generalLog_filepath = TEST3_GENERAL_LOG; starting_k = 5; max_k = 20; ignore_count = 3; if( getenv("SUDO_UID") ) { user_uid = atoi(getenv("SUDO_UID")); } else { printf("You need sudo to run the test\n"); exit(0); } #ifdef HARD_UPPER_LIMIT if( argc > 1 ) { upper_limit = atoi(argv[1]); } #endif if( argc > 2 ) { num_of_clients = atoi(argv[2]); } seteuid(user_uid); setfsuid(user_uid); setup_logs(); // Statistical variables running_stats_t rs; //set_default_running_stats( &rs ); create_service("group",group_count); for( l=1; l <= sizeof(group_size_array)/sizeof(int); l++) { group_size = group_size_array[l-1]; num_of_clients = group_size; set_default_running_stats( &rs ); printf("===================Pre-test Runs=====================\n"); for( j = 0; j < ignore_count; j++ ) { // ignore first few iterations timeLog_file = fopen( timeLog_filepath, "w" ); fclose(timeLog_file); test3( timeLog_filepath, num_of_clients, 1); } printf("===================Starting KSM1=====================\n"); resultsLogRAW_file = fopen( resultsLogRAW_filepath, "a" ); fprintf(resultsLogRAW_file, "===================Starting KSM1=====================\n"); if(resultsLogRAW_file) fclose(resultsLogRAW_file); run_test3(&rs, num_of_clients, 1); log_data( test3_dat_ksm1_filepath, group_size, &rs ); set_default_running_stats( &rs ); printf("===================Pre-test Runs=====================\n"); for( j = 0; j < ignore_count; j++ ) { // ignore first few iterations timeLog_file = fopen( timeLog_filepath, "w" ); fclose(timeLog_file); test3( timeLog_filepath, num_of_clients, 2); } printf("===================Starting KSM2=====================\n"); resultsLogRAW_file = fopen( resultsLogRAW_filepath, "a" ); fprintf(resultsLogRAW_file, "===================Starting KSM2=====================\n"); if(resultsLogRAW_file) fclose(resultsLogRAW_file); run_test3(&rs, num_of_clients, 2); log_data( test3_dat_ksm2_filepath, group_size, &rs ); } delete_service("group",group_count); merge_data(test3_dat_filepath, test3_dat_ksm1_filepath, test3_dat_ksm2_filepath); remove(test3_dat_ksm1_filepath); remove(test3_dat_ksm2_filepath); remove(timeLog_filepath); return 0; }