23 assert(chunksize<UINT_MAX);
34 const unsigned ntotbytes = length_of_mem-
sizeof(
LWPoolArea);
37 nchunks = ntotbytes/chunksize;
43 nchunks -= (-balance)/chunksize;
55 if (wastage*1.0>0.05*ntotbytes||wastage>640) {
56 std::cout<<
"LWHist MemPool (chunksize: "<<chunksize<<
") WARNING: Wasting "
57 <<wastage<<
" bytes per area ("<<(wastage*100.0/ntotbytes)<<
" %)"<<std::endl;
59 std::cout<<
"chunksize "<<chunksize<<
": totsize:"<<length_of_mem<<std::endl;
60 std::cout<<
"chunksize "<<chunksize<<
": sizeof(LWPoolArea):"<<
sizeof(
LWPoolArea)<<std::endl;
62 unsigned bytes_useful(nchunks*chunksize);
63 unsigned bytes_overhead(length_of_mem-bytes_useful);
64 std::cout<<
"chunksize "<<chunksize<<
": nchunks:"<<nchunks<<
" => "<<bytes_useful<<
" bytes"<<std::endl;
65 std::cout<<
"chunksize "<<chunksize<<
": rounding wastage:"<<wastage<<std::endl;
66 std::cout<<
"chunksize "<<chunksize<<
": total overhead:"
67 <<bytes_overhead<<
" ("<<bytes_overhead*100.0/bytes_useful<<
"% ~ "
68 <<bytes_overhead*CHAR_BIT*1.0/nchunks<<
" bits/chunk)"<<std::endl;