Changeset 14801 for trunk


Ignore:
Timestamp:
01/31/13 11:49:13 (12 years ago)
Author:
tbretz
Message:
Display compression ratio with higher precision, added an example algorithm to compress the data slightly better (~4%)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/zfits.cc

    r14797 r14801  
    160160
    161161            // If the column is the data, preprocess the data
     162            /*
    162163            if (it->second.name=="Data")
    163             { /*
    164                 // e.g. subtract the median (note that this is just
    165                 // to test the properties of the compression, because
    166                 // it re-sorts the real data and does not keep the
    167                 // subtracted offset in the output
    168                 int n = 30;
    169                 vector<int16_t> med(1440*n);
    170                 for (int i=0; i<1440*n; i++)
     164            {
     165                int16_t *end = ptr+1440*300-2-300%2;
     166                int16_t *beg = ptr;
     167
     168                while (end>=beg)
    171169                {
    172                     int16_t *chunk = ptr+i*300/n;
    173                     sort(chunk, chunk+300/n);
    174 
    175                     med[i] = chunk[300/n/2];
    176 
    177                     for (int j=0; j<300/n; j++)
    178                         chunk[j] -= med[i];
     170                    const int16_t avg = (end[0] + end[1])/2;
     171                    end[2] -= avg;
     172                    end[3] -= avg;
     173                    end -=2;
    179174                }
    180 
    181                 string buf;
    182                 int len = huffmans_encode(buf, (uint16_t*)med.data(), med.size());
    183                 com += buf.size();*/
    184             }
     175            }*/
    185176
    186177            // do not try to compress less than 32bytes
     
    234225        {
    235226            const double elep = Time().UnixTime()-start.UnixTime();
    236             cout << "\r" << setprecision(0) << setw(3) << 100*proc << "% [" << setw(3) << 100.*com/tot << "%] cpu:" << setprecision(1) << sec << "s in:" << tot/1000000/elep << "MB/s" << flush;
     227            cout << "\r" << setprecision(0) << setw(3) << 100*proc << "% [" << setprecision(1) << setw(5) << 100.*com/tot << "%] cpu:" << sec << "s in:" << tot/1000000/elep << "MB/s" << flush;
    237228            frac += 0.01;
    238229        }
     
    240231
    241232    const double elep = Time().UnixTime()-start.UnixTime();
    242     cout << setprecision(0) << "\r100% [" << setw(3) << 100.*com/tot << "%] cpu:" << setprecision(1) << sec << "s in:" << tot/1000000/elep << "MB/s" << endl;
     233    cout << setprecision(0) << "\r100% [" << setprecision(1) << setw(5) << 100.*com/tot << "%] cpu:" << sec << "s in:" << tot/1000000/elep << "MB/s" << endl;
    243234
    244235    return 0;
     
    393384        {
    394385            const double elep = Time().UnixTime()-start.UnixTime();
    395             cout << "\r" << setprecision(0) << setw(3) << 100*proc << "% [" << setw(3) << 100.*com/tot << "%] cpu:" << setprecision(1) << sec << "s out:" << tot/1000000/elep << "MB/s" << flush;
     386            cout << "\r" << setprecision(0) << setw(3) << 100*proc << "% [" << setprecision(1) << setw(5) << 100.*com/tot << "%] cpu:" << sec << "s out:" << tot/1000000/elep << "MB/s" << flush;
    396387            frac += 0.01;
    397388        }
     
    399390
    400391    const double elep = Time().UnixTime()-start.UnixTime();
    401     cout << setprecision(0) << "\r100% [" << setw(3) << 100.*com/tot << "%] cpu:" << setprecision(1) << sec << "s out:" << tot/1000000/elep << "MB/s" << endl;
     392    cout << setprecision(0) << "\r100% [" << setprecision(1) << setw(5) << 100.*com/tot << "%] cpu:" << sec << "s out:" << tot/1000000/elep << "MB/s" << endl;
    402393
    403394    return 0;
Note: See TracChangeset for help on using the changeset viewer.