A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
time-data-calculators.cc
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2008 Drexel University
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Joe Kopena (tjkopena@cs.drexel.edu)
19
*/
20
21
#include "ns3/log.h"
22
#include "ns3/nstime.h"
23
24
#include "time-data-calculators.h"
25
26
using namespace
ns3;
27
28
NS_LOG_COMPONENT_DEFINE
(
"TimeDataCalculators"
);
29
30
31
//--------------------------------------------------------------
32
//----------------------------------------------
33
TimeMinMaxAvgTotalCalculator::TimeMinMaxAvgTotalCalculator()
34
{
35
m_count = 0;
36
}
37
TimeMinMaxAvgTotalCalculator::~TimeMinMaxAvgTotalCalculator()
38
{
39
}
40
void
41
TimeMinMaxAvgTotalCalculator::DoDispose
(
void
)
42
{
43
DataCalculator::DoDispose
();
44
// TimeMinMaxAvgTotalCalculator::DoDispose
45
}
46
47
void
48
TimeMinMaxAvgTotalCalculator::Update (
const
Time
i)
49
{
50
if
(m_enabled) {
51
if
(m_count) {
52
m_total += i;
53
54
if
(i < m_min)
55
m_min = i;
56
57
if
(i > m_max)
58
m_max = i;
59
60
}
else
{
61
m_min = i;
62
m_max = i;
63
m_total = i;
64
}
65
m_count++;
66
67
}
68
// end TimeMinMaxAvgTotalCalculator::Update
69
}
70
void
71
TimeMinMaxAvgTotalCalculator::Output (
DataOutputCallback
&callback)
const
72
{
73
callback.OutputSingleton (m_context, m_key +
"-count"
, m_count);
74
if
(m_count > 0) {
75
callback.OutputSingleton (m_context, m_key +
"-total"
, m_total);
76
callback.OutputSingleton (m_context, m_key +
"-average"
,
Time
(m_total / m_count));
77
callback.OutputSingleton (m_context, m_key +
"-max"
, m_max);
78
callback.OutputSingleton (m_context, m_key +
"-min"
, m_min);
79
}
80
// end TimeMinMaxAvgTotalCalculator::Output
81
}
ns3::Time
keep track of time unit.
Definition:
nstime.h:149
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Definition:
log.h:122
ns3::TimeMinMaxAvgTotalCalculator::DoDispose
virtual void DoDispose(void)
Definition:
time-data-calculators.cc:41
ns3::DataCalculator::DoDispose
virtual void DoDispose(void)
Definition:
data-calculator.cc:47
ns3::DataOutputCallback
Definition:
data-output-interface.h:60
src
stats
model
time-data-calculators.cc
Generated on Sun Mar 16 2014 11:25:10 for ns-3 by
1.8.6