Fork me on GitHub

source: git/external/ExRootAnalysis/ExRootProgressBar.cc@ 12b11f9

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 12b11f9 was d7d2da3, checked in by pavel <pavel@…>, 12 years ago

move branches/ModularDelphes to trunk

  • Property mode set to 100644
File size: 1.8 KB
Line 
1
2/** \class ExRootProgressBar
3 *
4 * Class showing progress bar
5 *
6 * $Date: 2008-06-04 13:57:55 $
7 * $Revision: 1.1 $
8 *
9 *
10 * \author P. Demin - UCL, Louvain-la-Neuve
11 *
12 */
13
14#include "ExRootAnalysis/ExRootProgressBar.h"
15
16#include "TSystem.h"
17
18#include <iostream>
19
20#include <string.h>
21#include <stdio.h>
22
23using namespace std;
24
25ExRootProgressBar::ExRootProgressBar(Long64_t entries, Int_t width) :
26 fEntries(entries), fEventCounter(0), fWidth(width), fTime(0), fHashes(-1), fBar(0)
27{
28 fBar = new char[width + 1];
29 memset(fBar, '-', width);
30 fBar[width] = 0;
31}
32
33//------------------------------------------------------------------------------
34
35ExRootProgressBar::~ExRootProgressBar()
36{
37 if(fBar) delete[] fBar;
38}
39
40//------------------------------------------------------------------------------
41
42void ExRootProgressBar::Update(Long64_t entry, Long64_t eventCounter, Bool_t last)
43{
44 ULong64_t time = gSystem->Now();
45
46 if(time < fTime + 500 && entry < fEntries && !last) return;
47
48 fTime = time;
49
50 if(fEntries > 0)
51 {
52 Int_t hashes = Int_t(Double_t(entry)/fEntries*fWidth);
53 if(hashes > fWidth) hashes = fWidth;
54 if(hashes != fHashes)
55 {
56 memset(fBar, '#', hashes);
57 memset(fBar + hashes, '-', fWidth - hashes);
58 fHashes = hashes;
59 fprintf(stderr, "** [%s] (%.2f%%)\r", fBar, Float_t(entry)/fEntries*100.0);
60 }
61 }
62 else
63 {
64 if(eventCounter > fEventCounter)
65 {
66 fEventCounter = eventCounter;
67 fprintf(stderr, "** %lld events processed\r", eventCounter);
68 }
69 }
70
71 fflush(stderr);
72}
73
74//------------------------------------------------------------------------------
75
76void ExRootProgressBar::Finish()
77{
78 fprintf(stderr, "\n");
79 fflush(stderr);
80}
81
82//------------------------------------------------------------------------------
83
Note: See TracBrowser for help on using the repository browser.