File: Statistics.cc

package info (click to toggle)
topcom 1.1.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 31,784 kB
  • sloc: cpp: 37,616; sh: 4,262; makefile: 497; ansic: 49
file content (45 lines) | stat: -rw-r--r-- 1,597 bytes parent folder | download | duplicates (2)
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
////////////////////////////////////////////////////////////////////////////////
// 
// Statistics.cc
//
//    produced: 17 Sep 2021 jr
// last change: 17 Sep 2021 jr
//
////////////////////////////////////////////////////////////////////////////////

#include <iostream>
#include <thread>
#include <cstdlib>

#include "Statistics.hh"

namespace topcom {

  std::fstream Statistics::_stats_stream;
  size_type    Statistics::_no_of_map_calls = 0;

  // initialization:
  void Statistics::init() {
     std::cerr << "initializing statistics output ..." << std::endl;
      
      std::cerr << "... output file: " << CommandlineOptions::stats_file() << " ..." << std::endl;
      Statistics::stats_stream().open(CommandlineOptions::stats_file(), std::ios::out | std::ios::trunc);
      Statistics::stats_stream() << "//////////////////////////////////////////////////////////////////////////////" << std::endl;
      Statistics::stats_stream() << "// statistics file (automatically generated by TOPCOM)" << std::endl;
      Statistics::stats_stream() << "//////////////////////////////////////////////////////////////////////////////" << std::endl;
      Statistics::stats_stream() << std::endl;
      std::cerr << "... done." << std::endl;
    }

  // termination:
  void Statistics::term() {
    std::cerr << "terminating statistics output ..." << std::endl;
    Statistics::stats_stream() << "no of map calls: \t" << _no_of_map_calls << std::endl;
    Statistics::stats_stream().close();
    std::cerr << "... done." << std::endl;    
  }

  
}; // namespace topcom

// eof CommandlineOptions.cc