File: Statistics.hh

package info (click to toggle)
topcom 1.2.0~beta%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 148,596 kB
  • sloc: cpp: 40,956; sh: 4,663; makefile: 679; ansic: 55
file content (57 lines) | stat: -rw-r--r-- 1,496 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
////////////////////////////////////////////////////////////////////////////////
// 
// Statistics.hh 
//
//    produced: 17 Sep 2021 jr
//
////////////////////////////////////////////////////////////////////////////////
#ifndef STATISTICS_HH
#define STATISTICS_HH

#include <stdlib.h>
#include <cstring>
#include <fstream>

#include "Global.hh"
#include "CommandlineOptions.hh"
#include "ContainerIO.hh"

namespace topcom {

  // statistical data is collected in a purely static class (i.e., a global variable):
  class Statistics {
  private:
    static std::fstream _stats_stream;
    static size_type    _no_of_singleton_map_calls;
    static size_type    _no_of_structure_map_calls;
  public:
    Statistics() {}
    Statistics(const Statistics&) {}
  public:
    // initialization:
    static void init();
    
    // termination:
    static void term();

    // report:
    static void report();

    // reset:
    static void reset();
    
    // accessors:
    inline static std::fstream& stats_stream()          { return _stats_stream; }
    inline static size_type no_of_singleton_map_calls() { return _no_of_singleton_map_calls; }
    inline static size_type no_of_structure_map_calls() { return _no_of_structure_map_calls; }

    // modifiers:
    inline static void new_singleton_map_call()         { ++_no_of_singleton_map_calls; }
    inline static void new_structure_map_call()         { ++_no_of_structure_map_calls; }
  };

}; // namespace topcom

#endif

// eof Statistics.hh