Fork me on GitHub

Changeset 251 in svn for trunk/Utilities/ExRootAnalysis


Ignore:
Timestamp:
Feb 7, 2009, 4:44:02 PM (16 years ago)
Author:
severine ovyn
Message:

add progress bar

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Utilities/ExRootAnalysis/src/ExRootProgressBar.cc

    r220 r251  
    44 *  Class showing progress bar
    55 *
    6  *  $Date: 2009-02-02 11:32:01 $
    7  *  $Revision: 1.2 $
     6 *  $Date: 2009-02-07 15:44:02 $
     7 *  $Revision: 1.3 $
    88 *
    99 *
     
    1515#include "TSystem.h"
    1616#include <cstdio>
     17#include <iostream>
    1718
    1819using namespace std;
     
    3132ExRootProgressBar::~ExRootProgressBar()
    3233{
    33   if(fBar) delete[] fBar;
     34   if(fBar) delete[] fBar;
    3435}
    3536
     
    4041  ULong_t time = gSystem->Now();
    4142
    42   if(time < fTime + 1000 && entry < fEntries - 1) return;
     43  if(time < fTime + 500 && entry < fEntries - 1) return;
    4344
    4445  fTime = time;
     
    4849  if(hashes > fHashes)
    4950  {
    50     memset(fBar + fHashes, '#', hashes - fHashes);
     51    memset(fBar + fHashes, '$', hashes - fHashes);
    5152    fHashes = hashes;
    5253  }
     54 float frac=(entry + 1.0)/fEntries*100.0;
     55 if(frac<10)   fprintf(stdout, "**         [%s] %.2f%% processed             **\r", fBar,(entry + 1.0)/fEntries*100.0);
     56 if(frac==100) fprintf(stdout, "**         [%s] %.2f%% processed           **\r", fBar,(entry + 1.0)/fEntries*100.0);
     57 else          fprintf(stdout, "**         [%s] %.2f%% processed            **\r", fBar,(entry + 1.0)/fEntries*100.0);
     58  fflush(stdout);
    5359
    54 /*
    55   cerr << "[" << fBar << "] (";
    56   cerr.setf(ios::fixed);
    57   cerr.precision(2);
    58   cerr << (entry + 1.0)/fEntries*100.0 << "%) : ";
    59   cerr << entry + 1 << "/" << fEntries;
    60   cerr << " events processed\r" << flush;
    61 */
    62 
    63   fprintf(stderr, "[%s] (%.2f%%) : %lli/%lli entries processed\r", fBar,
    64           (entry + 1.0)/fEntries*100.0, entry + 1, fEntries);
    65   fflush(stderr);
     60  if(entry+1==fEntries)
     61    {
     62       char temp[500];
     63       sprintf(temp, "**         [%s] %.2f%% processed ", fBar,(entry + 1.0)/fEntries*100.0);
     64       string mystringName(temp);
     65       cout << mystringName <<endl;
     66    }
    6667}
    6768
Note: See TracChangeset for help on using the changeset viewer.