%description: Test saveToFile()/loadFromFile() for various histogram classes. %activity: #if defined(__clang__) || defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif int numCells = 10; int numFirstVals = 100; double rangeExtFactor = 1.3; cDoubleHistogram dblhist("DoubleHistogram", numCells); cLongHistogram longhist("LongHistogram", numCells); cVarHistogram varhist("VarHistogram", numCells, cVarHistogram::HIST_TR_AUTO_EPC_DBL); cPSquare psquare("PSquare", numCells); cKSplit ksplit("K-Split"); // NOTE: Something equivalent already exists for cHistogram. dblhist.setRangeAutoUpper(0.0, numFirstVals, rangeExtFactor); longhist.setRangeAutoUpper(0.0, numFirstVals, rangeExtFactor); ksplit.setRangeAutoUpper(0.0, numFirstVals, rangeExtFactor); for (int i = 0; i < 1000; i++) { double d = (intrand(2) == 0) ? exponential(30) : normal(80, 10); longhist.collect(d); dblhist.collect(d); psquare.collect(d); ksplit.collect(d); varhist.collect(d); } FILE *f = fopen("pass1.txt", "w"); longhist.saveToFile(f); dblhist.saveToFile(f); psquare.saveToFile(f); varhist.saveToFile(f); ksplit.saveToFile(f); fclose(f); f = fopen("pass1.txt", "r"); longhist.loadFromFile(f); dblhist.loadFromFile(f); psquare.loadFromFile(f); varhist.loadFromFile(f); ksplit.loadFromFile(f); fclose(f); f = fopen("pass2.txt", "w"); longhist.saveToFile(f); dblhist.saveToFile(f); psquare.saveToFile(f); varhist.saveToFile(f); ksplit.saveToFile(f); fclose(f); #if defined(__clang__) || defined(__GNUC__) #pragma GCC diagnostic pop #endif %postrun-command: diff pass1.txt pass2.txt %subst: /e\+0(\d\d)/e+\1/ %contains: pass1.txt # # (omnetpp::cLongHistogram) Test.LongHistogram # 1000 #= num_vals 0 217 #= min, max 0 #= weighted 55149 #= sum 4.16791e+06 #= sum_squared_vals 1 #= transformed 2 #= range_mode 1.3 #= range_ext_factor 0 160 #= range 0 1 #= cell_under, cell_over 0 1 #= sumweights_underflow, sum_weights_overflow 100 #= num_firstvals 0 #= firstvals[] exists 10 #= num_cells 1 #= cellv[] exists 207 116 70 55 269 226 41 11 1 3 16 #= cellsize # # (omnetpp::cDoubleHistogram) Test.DoubleHistogram # 1000 #= num_vals 0.0415294 217.004 #= min, max 0 #= weighted 55653.6 #= sum 4.22383e+06 #= sum_squared_vals 1 #= transformed 2 #= range_mode 1.3 #= range_ext_factor 0 151.771 #= range 0 1 #= cell_under, cell_over 0 1 #= sumweights_underflow, sum_weights_overflow 100 #= num_firstvals 0 #= firstvals[] exists 10 #= num_cells 1 #= cellv[] exists 197 120 69 45 190 280 78 12 4 4 15.1771 #= cellsize # # (omnetpp::cPSquare) Test.PSquare # 1000 #= num_vals 0.0415294 217.004 #= min, max 0 #= weighted 55653.6 #= sum 4.22383e+06 #= sum_squared_vals 10 #= numbins 1000 #= numobs #= n[] 0 1 101 200 300 400 500 600 700 801 900 1000 #= q[] -1.79769e+308 0.0415294 7.66721 15.1703 26.9537 50.6354 68.315 74.8863 79.112 84.5245 92.1503 217.004 # # (omnetpp::cVarHistogram) Test.VarHistogram # 1000 #= num_vals 0.0415294 217.004 #= min, max 0 #= weighted 55653.6 #= sum 4.22383e+06 #= sum_squared_vals 1 #= transformed 4 #= range_mode 2 #= range_ext_factor 0.569057 116.747 #= range 6 9 #= cell_under, cell_over 6 9 #= sumweights_underflow, sum_weights_overflow 100 #= num_firstvals 0 #= firstvals[] exists 10 #= num_cells 1 #= cellv[] exists 112 71 97 43 119 93 160 115 96 79 1 #= transform_type 10 #= max_num_cells 1 #= bin_bounds[] exists 0.569057 8.62231 14.6567 25.4766 33.0254 64.2744 71.5244 79.0794 85.6448 91.7368 116.747 # # (omnetpp::cKSplit) Test.K-Split # 1000 #= num_vals 0.0415294 217.004 #= min, max 0 #= weighted 55653.6 #= sum 4.22383e+06 #= sum_squared_vals 1 #= transformed 2 #= range_mode 1.3 #= range_ext_factor 0 303.542 #= range 0 0 #= cell_under, cell_over 0 0 #= sumweights_underflow, sum_weights_overflow 100 #= num_firstvals 0 #= firstvals[] exists 13 #= num_cells 16 #= gridv_size 11 #= rootgrid 12 #= lastgrid 1 #= gridv_exists # grid 1 11 #= parent 0 #= reldepth 999 #= total 0 #= mother -2 -3 #= cells[0], cells[1] # grid 2 1 #= parent 1 #= reldepth 621 #= total 0 #= mother -4 -6 #= cells[0], cells[1] # grid 3 1 #= parent 1 #= reldepth 378 #= total 0 #= mother -5 13 #= cells[0], cells[1] # grid 4 2 #= parent 2 #= reldepth 356 #= total 0 #= mother -8 -9 #= cells[0], cells[1] # grid 5 3 #= parent 2 #= reldepth 365 #= total 0 #= mother -7 50 #= cells[0], cells[1] # grid 6 2 #= parent 2 #= reldepth 265 #= total 23 #= mother 53 -10 #= cells[0], cells[1] # grid 7 5 #= parent 3 #= reldepth 315 #= total 40 #= mother -12 108 #= cells[0], cells[1] # grid 8 4 #= parent 3 #= reldepth 236 #= total 40 #= mother 106 90 #= cells[0], cells[1] # grid 9 4 #= parent 3 #= reldepth 120 #= total 40 #= mother 46 34 #= cells[0], cells[1] # grid 10 6 #= parent 3 #= reldepth 189 #= total 40 #= mother 43 106 #= cells[0], cells[1] # grid 11 0 #= parent -1 #= reldepth 1000 #= total 0 #= mother -1 1 #= cells[0], cells[1] # grid 12 7 #= parent 4 #= reldepth 167 #= total 160 #= mother 4 3 #= cells[0], cells[1] %contains: pass2.txt # # (omnetpp::cLongHistogram) Test.LongHistogram # 1000 #= num_vals 0 217 #= min, max 0 #= weighted 55149 #= sum 4.16791e+06 #= sum_squared_vals 1 #= transformed 2 #= range_mode 1.3 #= range_ext_factor 0 160 #= range 0 1 #= cell_under, cell_over 0 1 #= sumweights_underflow, sum_weights_overflow 100 #= num_firstvals 0 #= firstvals[] exists 10 #= num_cells 1 #= cellv[] exists 207 116 70 55 269 226 41 11 1 3 16 #= cellsize # # (omnetpp::cDoubleHistogram) Test.DoubleHistogram # 1000 #= num_vals 0.0415294 217.004 #= min, max 0 #= weighted 55653.6 #= sum 4.22383e+06 #= sum_squared_vals 1 #= transformed 2 #= range_mode 1.3 #= range_ext_factor 0 151.771 #= range 0 1 #= cell_under, cell_over 0 1 #= sumweights_underflow, sum_weights_overflow 100 #= num_firstvals 0 #= firstvals[] exists 10 #= num_cells 1 #= cellv[] exists 197 120 69 45 190 280 78 12 4 4 15.1771 #= cellsize # # (omnetpp::cPSquare) Test.PSquare # 1000 #= num_vals 0.0415294 217.004 #= min, max 0 #= weighted 55653.6 #= sum 4.22383e+06 #= sum_squared_vals 10 #= numbins 1000 #= numobs #= n[] 0 1 101 200 300 400 500 600 700 801 900 1000 #= q[] -1.79769e+308 0.0415294 7.66721 15.1703 26.9537 50.6354 68.315 74.8863 79.112 84.5245 92.1503 217.004 # # (omnetpp::cVarHistogram) Test.VarHistogram # 1000 #= num_vals 0.0415294 217.004 #= min, max 0 #= weighted 55653.6 #= sum 4.22383e+06 #= sum_squared_vals 1 #= transformed 4 #= range_mode 2 #= range_ext_factor 0.569057 116.747 #= range 6 9 #= cell_under, cell_over 6 9 #= sumweights_underflow, sum_weights_overflow 100 #= num_firstvals 0 #= firstvals[] exists 10 #= num_cells 1 #= cellv[] exists 112 71 97 43 119 93 160 115 96 79 1 #= transform_type 10 #= max_num_cells 1 #= bin_bounds[] exists 0.569057 8.62231 14.6567 25.4766 33.0254 64.2744 71.5244 79.0794 85.6448 91.7368 116.747 # # (omnetpp::cKSplit) Test.K-Split # 1000 #= num_vals 0.0415294 217.004 #= min, max 0 #= weighted 55653.6 #= sum 4.22383e+06 #= sum_squared_vals 1 #= transformed 2 #= range_mode 1.3 #= range_ext_factor 0 303.542 #= range 0 0 #= cell_under, cell_over 0 0 #= sumweights_underflow, sum_weights_overflow 100 #= num_firstvals 0 #= firstvals[] exists 13 #= num_cells 16 #= gridv_size 11 #= rootgrid 12 #= lastgrid 1 #= gridv_exists # grid 1 11 #= parent 0 #= reldepth 999 #= total 0 #= mother -2 -3 #= cells[0], cells[1] # grid 2 1 #= parent 1 #= reldepth 621 #= total 0 #= mother -4 -6 #= cells[0], cells[1] # grid 3 1 #= parent 1 #= reldepth 378 #= total 0 #= mother -5 13 #= cells[0], cells[1] # grid 4 2 #= parent 2 #= reldepth 356 #= total 0 #= mother -8 -9 #= cells[0], cells[1] # grid 5 3 #= parent 2 #= reldepth 365 #= total 0 #= mother -7 50 #= cells[0], cells[1] # grid 6 2 #= parent 2 #= reldepth 265 #= total 23 #= mother 53 -10 #= cells[0], cells[1] # grid 7 5 #= parent 3 #= reldepth 315 #= total 40 #= mother -12 108 #= cells[0], cells[1] # grid 8 4 #= parent 3 #= reldepth 236 #= total 40 #= mother 106 90 #= cells[0], cells[1] # grid 9 4 #= parent 3 #= reldepth 120 #= total 40 #= mother 46 34 #= cells[0], cells[1] # grid 10 6 #= parent 3 #= reldepth 189 #= total 40 #= mother 43 106 #= cells[0], cells[1] # grid 11 0 #= parent -1 #= reldepth 1000 #= total 0 #= mother -1 1 #= cells[0], cells[1] # grid 12 7 #= parent 4 #= reldepth 167 #= total 160 #= mother 4 3 #= cells[0], cells[1]