1
0
mirror of https://github.com/wfjm/w11.git synced 2026-05-05 15:44:35 +00:00

add -reset option to stats subcommand

- librtools/Rstats: add Reset(); drop operator-=() and operator*=()
- librtcltools/RtclStats: Rename Collect->Exec, not longer const; add -reset
- libr*/*: Stats() not longer const; use RtclStats::Exec()
This commit is contained in:
wfjm
2019-06-08 09:02:24 +02:00
parent 600dd42e69
commit 07909777df
42 changed files with 186 additions and 158 deletions

View File

@@ -1,6 +1,6 @@
// $Id: Rstats.cpp 1089 2018-12-19 10:45:41Z mueller $
// $Id: Rstats.cpp 1160 2019-06-07 17:30:17Z mueller $
//
// Copyright 2011-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2019-06-07 1160 1.0.6 add Reset(); drop operator-=() and operator*=()
// 2018-12-18 1089 1.0.5 use c++ style casts
// 2017-02-04 865 1.0.4 add NameMaxLength(); Print(): add counter name
// 2017-02-18 851 1.0.3 add IncLogHist; fix + and * operator definition
@@ -111,6 +112,15 @@ void Rstats::Define(size_t ind, const std::string& name,
//------------------------------------------+-----------------------------------
//! FIXME_docs
void Rstats::Reset()
{
for (auto& o: fValue) o = 0.;
return;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
void Rstats::IncLogHist(size_t ind, size_t maskfirst,
size_t masklast, size_t val)
{
@@ -231,31 +241,4 @@ Rstats& Rstats::operator=(const Rstats& rhs)
return *this;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
Rstats& Rstats::operator-=(const Rstats& rhs)
{
if (Size() != rhs.Size() || fHash != rhs.fHash) {
throw Rexception("Rstats::oper-()",
"Bad args: subtract incompatible stats");
}
for (size_t i=0; i<fValue.size(); i++) {
fValue[i] -= rhs.fValue[i];
}
return *this;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
Rstats& Rstats::operator*=(double rhs)
{
for (size_t i=0; i<fValue.size(); i++) {
fValue[i] *= rhs;
}
return *this;
}
} // end namespace Retro

View File

@@ -1,6 +1,6 @@
// $Id: Rstats.hpp 983 2018-01-02 20:35:59Z mueller $
// $Id: Rstats.hpp 1160 2019-06-07 17:30:17Z mueller $
//
// Copyright 2011-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// This program is free software; you may redistribute and/or modify it under
// the terms of the GNU General Public License as published by the Free
@@ -13,6 +13,7 @@
//
// Revision History:
// Date Rev Version Comment
// 2019-06-07 1160 1.0.3 add Reset(); drop operator-=() and operator*=()
// 2017-02-04 865 1.0.2 add NameMaxLength(); Dump(): add detail arg
// 2017-02-18 851 1.0.1 add IncLogHist; fix + and * operator definition
// 2011-02-06 359 1.0 Initial version
@@ -46,6 +47,8 @@ namespace Retro {
void Set(size_t ind, double val);
void Inc(size_t ind, double val=1.);
void Reset();
void IncLogHist(size_t ind, size_t maskfirst,
size_t masklast, size_t val);
@@ -65,8 +68,6 @@ namespace Retro {
double operator[](size_t ind) const;
Rstats& operator=(const Rstats& rhs);
Rstats& operator-=(const Rstats& rhs);
Rstats& operator*=(double rhs);
private:
std::vector<double> fValue; //!< counter value