void process_test_stream(void) { int forever = TRUE; char *callsign; double lat, lon, alt; date_time_t wall_time; time_t last_store = 0; init_test_data(); while (forever) { PMU_auto_register("Got data"); get_test_data(&callsign, &lat, &lon, &alt); /* * substitute wall clock time for gps time */ wall_time.unix_time = time(NULL); uconvert_from_utime(&wall_time); if((wall_time.unix_time - last_store) >= Glob->params.data_interval) { store_line(&wall_time, lat, lon, alt, callsign, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0); if (Glob->params.use_spdb) { if (Glob->params.single_database) { store_single_spdb(&wall_time, lat, lon, alt, callsign); } else { store_mult_spdb(&wall_time, lat, lon, alt, callsign); } } /* if (Glob->params.use_spdb) */ last_store = wall_time.unix_time; } /* if((wall_time.unix_time - last_store) ... */ sleep(1); } /* while (forever) */ free_test_data(); }
void InfoTestData::get_data(const std::wstring &name, size_t &nRows, size_t &nCols, std::vector<int> &data, std::vector<std::wstring> &indNames, std::vector<std::wstring> &varNames) { nRows = 0; nCols = 0; data.clear(); indNames.clear(); varNames.clear(); if (name == wst_mortal_name) { std::wstring s; get_mortal_data(s, nRows, nCols, data, indNames, varNames); } else if (name == wst_conso_name) { std::wstring s; get_mortal_data(s, nRows, nCols, data, indNames, varNames); } else if (name == wst_test_name) { std::wstring s; get_test_data(s, nRows, nCols, data, indNames, varNames); } }// get_data
auto file = std::unique_ptr<std::ifstream>( new std::ifstream(path, std::ios::binary) ); if (!file->is_open()) { FAIL("File could not be opened. This is the fault of the test code"); } return file; } /* * TEST CASES */ TEST_CASE ( "Individual sections are parsed" ) { SECTION("Time") { // expected objects don't resemble data, and are designed // to be easy to make and check against auto file = get_test_data("ts.test"); ts actual; read_time(*file, actual); REQUIRE(actual.sec == 0); REQUIRE(actual.min == 1); REQUIRE(actual.hour == 2); REQUIRE(actual.mday == 3); REQUIRE(actual.mon == 4); REQUIRE(actual.year == 5); REQUIRE(actual.wday == 6); REQUIRE(actual.yday == 7); REQUIRE(actual.isdst == 8); REQUIRE(actual.year_s == 9); } SECTION("Header") {
int main(int argc, char ** argv){ //first, read the data in files into an array in order to process it more efficiently. record_item_struct * item_data = (record_item_struct *) _mm_malloc(sizeof(record_item_struct)*RECORD_COUNT,64); memset(item_data, 0, sizeof(record_item_struct)*RECORD_COUNT); get_item_data(item_data, argv[1]); float * item_block_data_i = (float*)_mm_malloc(sizeof(float)*ITEM_BLOCK*USER_COUNT,64); float * item_block_data_j = (float*)_mm_malloc(sizeof(float)*ITEM_BLOCK*USER_COUNT,64); if (item_block_data_i==NULL || item_block_data_j == NULL) { printf(" malloc of base_data failed\n"); exit(1); } double * item_average_matrix = (double*)_mm_malloc(sizeof(double)*ITEM_COUNT,64); memset(item_average_matrix,0,sizeof(double)*ITEM_COUNT); k_similarity_struct * item_index_matrix = (k_similarity_struct *) _mm_malloc (sizeof(k_similarity_struct)*K_SORT*ITEM_COUNT,64); memset (item_index_matrix,-1,sizeof(k_similarity_struct)); int item_start_index_i=0; int item_start_index_j=0; // int i,j; for (int i=0; i <= ITEM_ROUND; i++) { printf("round %d ================== with ITEM_BLOCK %d\n",i,ITEM_BLOCK); //block_data printf("get item_block_data begins\n"); item_start_index_i = get_item_block_data(i, item_block_data_i,item_start_index_i, item_data); printf("get_item_block_data ends\n"); //average matrix printf("get_item_average_matrix begins\n"); get_item_average_matrix(item_block_data_i, item_average_matrix,i*ITEM_BLOCK); printf("get_item_average_matrix ends\n"); item_start_index_j = 0; for(int j=0; j<= i;j++) { if( i==j) { //the index of item after sorting the similarity matrix printf("get k_similarity_begins\n"); get_pearson_similarity(item_block_data_i,item_block_data_i,item_average_matrix,item_index_matrix,i*ITEM_BLOCK,i*ITEM_BLOCK,0); printf("get k_similarity_ends\n"); continue; } //block_data printf("get item_block_data begins\n"); item_start_index_j = get_item_block_data(j, item_block_data_j, item_start_index_j, item_data); printf("get_item_block_data ends\n"); //the index of item after sorting the similarity matrix printf("get k_similarity_begins\n"); get_pearson_similarity(item_block_data_i,item_block_data_j,item_average_matrix,item_index_matrix,i*ITEM_BLOCK,j*ITEM_BLOCK,1); printf("get k_similarity_ends\n"); } } _mm_free(item_block_data_i); _mm_free(item_block_data_j); int *test_data; float *test_rating; test_data = (int*)_mm_malloc (sizeof(int)*2*TEST_COUNT,64); test_rating= (float*)_mm_malloc(sizeof(float)*TEST_COUNT,64); printf("get_test_data begins\n"); get_test_data(test_data,test_rating); printf("get_test_data ends\n"); long user_file_start_index = 0; float * user_block_data = (float*)_mm_malloc(sizeof(float)*USER_BLOCK*ITEM_COUNT,64); if (user_block_data==NULL) { printf(" malloc of base_data failed\n"); exit(1); } int test_start_index = 0; double * item_predict_rating = (double*)_mm_malloc (sizeof(double)*TEST_COUNT,64); for(int i=0;i<=USER_ROUND;i++) { user_file_start_index = get_user_block_data(i,user_block_data, user_file_start_index); printf("get_predict_rating begins\n"); test_start_index=get_predict_rating(item_predict_rating, user_block_data, item_index_matrix, test_data,item_average_matrix,i*USER_BLOCK, test_start_index); printf("get_predict_rating ends\n"); if ( test_start_index == TEST_COUNT) break; } _mm_free (user_block_data); double rmse; printf("get_rmse begins\n"); rmse = get_rmse(test_rating,item_predict_rating); printf("ge_rmse ends\n"); printf("rmse= %f\n", rmse); return 0; }