Statistics
| Branch: | Revision:

root / src / envir / speedometer.h @ 68da4f12

History | View | Annotate | Download (1.39 KB)

1
//==========================================================================
2
//  SPEEDOMETER.H - part of
3
//                     OMNeT++/OMNEST
4
//             Discrete System Simulation in C++
5
//
6
//  Author: Andras Varga
7
//
8
//==========================================================================
9

    
10
/*--------------------------------------------------------------*
11
  Copyright (C) 1992-2008 Andras Varga
12
  Copyright (C) 2006-2008 OpenSim Ltd.
13

14
  This file is distributed WITHOUT ANY WARRANTY. See the file
15
  `license' for details on this and other legal matters.
16
*--------------------------------------------------------------*/
17

    
18

    
19
#ifndef __SPEEDOMETER_H
20
#define __SPEEDOMETER_H
21

    
22
#include "simkerneldefs.h"
23
#include "envirdefs.h"
24
#include "simtime_t.h"
25
#include "timeutil.h"
26

    
27
NAMESPACE_BEGIN
28

    
29

    
30
/**
31
 * Speedometer: utility class to measure simulation speed
32
 */
33
class ENVIR_API Speedometer
34
{
35
  private:
36
    bool started;
37
    long events;
38
    simtime_t current_simtime;
39
    simtime_t intvstart_simtime;
40
    timeval intvstart_walltime;
41
    double last_eventspersec;
42
    double last_eventspersimsec;
43
    double last_simsecpersec;
44

    
45
  public:
46
    Speedometer();
47

    
48
    void start(simtime_t t);
49
    void addEvent(simtime_t t);
50
    void beginNewInterval();
51

    
52
    unsigned long getMillisSinceIntervalStart();
53

    
54
    double getEventsPerSec();
55
    double getEventsPerSimSec();
56
    double getSimSecPerSec();
57
};
58

    
59
NAMESPACE_END
60

    
61
#endif
62