Skip to content
Snippets Groups Projects
Commit fa36ac1f authored by Veronique Legrand's avatar Veronique Legrand
Browse files

fixed calculation of the size of the CMS

parent eec34fa0
No related branches found
No related tags found
No related merge requests found
......@@ -31,9 +31,10 @@ class Filter {
ShortCountMinSketch * pShortCMS;
FasqQualThreshold qual_thres;
long nb_bytes_before_fill_CMS,nb_bytes_after_fill_CMS;
// long nb_bytes_before_fill_CMS,nb_bytes_after_fill_CMS;
long nb_bytes_CMS; //! Number of bytes taken by the underlying CMS.
void getRSS(int before_fill=0);
void getRSS();
template <typename T> void underlyingfillCMS(FqBaseBackend* map_id_backend[],int nb_be, int k, srp* io_sr, CountMinSketch<T>* cms);
......@@ -44,12 +45,12 @@ public:
Filter(const CMSparams& parms,const FasqQualThreshold& the_qual_thres) {
pByteCMS=NULL;
pShortCMS=NULL;
getRSS();
if (parms.kappa<ubytemask) pByteCMS=new ByteCountMinSketch(parms);
else pShortCMS=new ShortCountMinSketch(parms);
qual_thres=the_qual_thres;
nb_bytes_after_fill_CMS=0;
getRSS();
//nb_bytes_CMS=0;
//nb_bytes_after_fill_CMS=0;
}
void fillCMS(FqBaseBackend* map_id_backend[],int nb_be,int k,srp* io_sr);
......@@ -142,7 +143,7 @@ template <typename T> void Filter::underlyinglowFilterCMS(FqBaseBackend* map_id_
void Filter::fillCMS(FqBaseBackend* map_id_backend[],int nb_be,int k,srp* io_sr) {
if (pByteCMS!=NULL) underlyingfillCMS<unsigned char>(map_id_backend,nb_be, k, io_sr,pByteCMS);
else underlyingfillCMS<unsigned short>(map_id_backend,nb_be, k, io_sr,pShortCMS);
getRSS(1);
getRSS();
}
void Filter::lowFilterCMS(FqBaseBackend* map_id_backend[],int nb_be,int k, srp* io_sr) {
......@@ -160,16 +161,15 @@ std::vector<unsigned long> Filter::getUnsetBuckets() const {
else return pShortCMS->getUnsetBuckets();
}
void Filter::getRSS(int before_fill) {
void Filter::getRSS() {
struct rusage usage;
int res2=getrusage(RUSAGE_SELF,&usage);
if (res2==-1) err(errno,"cannot get resource usage.");
if (before_fill==0) nb_bytes_before_fill_CMS=usage.ru_maxrss;
else nb_bytes_after_fill_CMS=usage.ru_maxrss;
nb_bytes_CMS=usage.ru_maxrss;
}
unsigned long Filter::getSize() {
unsigned long cms_size=nb_bytes_after_fill_CMS-nb_bytes_before_fill_CMS;
unsigned long cms_size=nb_bytes_CMS;
// cms_size/=8; ru_maxrss seems to be already in Bytes.
return cms_size;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment