blob: 834004a25f50fd3d408301d9d97d200afb85246c [file] [log] [blame]
Alexander Afanasyev0845c092012-07-13 17:45:33 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2011 University of California, Los Angeles
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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 */
20
21#include "load-stats-face.h"
22
23namespace ndnSIM
24{
25
26void
27LoadStatsFace::Step ()
28{
29 m_count.Step ();
30 m_satisfied.Step ();
31 m_unsatisfied.Step ();
32}
33
34//
35LoadStats::stats_tuple
36LoadStatsFace::GetSatisfiedRatio () const
37{
38 return LoadStats::stats_tuple (m_satisfied.GetStats ().get<0> () / std::max (0.01, m_count.GetStats ().get<0> ()),
39 m_satisfied.GetStats ().get<1> () / std::max (0.01, m_count.GetStats ().get<1> ()),
40 m_satisfied.GetStats ().get<2> () / std::max (0.01, m_count.GetStats ().get<2> ()));
41}
42
43LoadStats::stats_tuple
44LoadStatsFace::GetUnsatisfiedRatio () const
45{
46 return LoadStats::stats_tuple (m_unsatisfied.GetStats ().get<0> () / std::max (0.01, m_count.GetStats ().get<0> ()),
47 m_unsatisfied.GetStats ().get<1> () / std::max (0.01, m_count.GetStats ().get<1> ()),
48 m_unsatisfied.GetStats ().get<2> () / std::max (0.01, m_count.GetStats ().get<2> ()));
49}
50
51LoadStatsFace &
52LoadStatsFace::operator += (const LoadStatsFace &load)
53{
54 m_count += load.m_count;
55 m_satisfied += load.m_satisfied;
56 m_unsatisfied += load.m_unsatisfied;
57
58 return *this;
59}
60
61std::ostream &
62operator << (std::ostream &os, const LoadStatsFace &stats)
63{
64 os << stats.m_count << "/" << stats.m_satisfied << "/" << stats.m_unsatisfied;
65 return os;
66}
67
68}