~ubuntu-branches/ubuntu/utopic/sip-tester/utopic

« back to all changes in this revision

Viewing changes to reporttask.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2010-06-13 16:15:44 UTC
  • mto: This revision was merged to the branch mainline in revision 7.
  • Revision ID: james.westby@ubuntu.com-20100613161544-34ke9f9x5kole5p3
Tags: upstream-3.1
ImportĀ upstreamĀ versionĀ 3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  This program is free software; you can redistribute it and/or modify
3
 
 *  it under the terms of the GNU General Public License as published by
4
 
 *  the Free Software Foundation; either version 2 of the License, or
5
 
 *  (at your option) any later version.
6
 
 *
7
 
 *  This program is distributed in the hope that it will be useful,
8
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 
 *  GNU General Public License for more details.
11
 
 *
12
 
 *  You should have received a copy of the GNU General Public License
13
 
 *  along with this program; if not, write to the Free Software
14
 
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15
 
 *
16
 
 *  Author : Richard GAYRAUD - 04 Nov 2003
17
 
 *           Marc LAMBERTON
18
 
 *           Olivier JACQUES
19
 
 *           Herve PELLAN
20
 
 *           David MANSUTTI
21
 
 *           Francois-Xavier Kowalski
22
 
 *           Gerard Lyonnaz
23
 
 *           From Hewlett Packard Company.
24
 
 *           F. Tarek Rogers
25
 
 *           Peter Higginson
26
 
 *           Vincent Luba
27
 
 *           Shriram Natarajan
28
 
 *           Guillaume Teissier from FTR&D
29
 
 *           Clement Chen
30
 
 *           Wolfgang Beck
31
 
 *           Charles P Wright from IBM Research
32
 
 */
33
 
#include "sipp.hpp"
34
 
 
35
 
class stattask *stattask::instance = NULL;
36
 
class screentask *screentask::instance = NULL;
37
 
 
38
 
void stattask::initialize() {
39
 
  assert(instance == NULL);
40
 
  if (dumpInFile || useCountf || rate_increase) {
41
 
    instance = new stattask();
42
 
  }
43
 
}
44
 
 
45
 
void screentask::initialize() {
46
 
  assert(instance == NULL);
47
 
  if (report_freq) {
48
 
    instance = new screentask();
49
 
  }
50
 
}
51
 
 
52
 
void stattask::dump() {
53
 
  WARNING("Statistics reporting task.");
54
 
}
55
 
void screentask::dump() {
56
 
  WARNING("Screen update task.");
57
 
}
58
 
 
59
 
void screentask::report(bool last) {
60
 
    print_statistics(last);
61
 
    display_scenario->stats->computeStat(CStat::E_RESET_PD_COUNTERS);
62
 
    last_report_time  = getmilliseconds();
63
 
    scheduling_loops = 0;
64
 
}
65
 
 
66
 
bool screentask::run() {
67
 
  if (quitting > 11) {
68
 
    delete this;
69
 
    return false;
70
 
  }
71
 
 
72
 
  if (getmilliseconds() - last_report_time >= report_freq) {
73
 
    report(false);
74
 
  }
75
 
 
76
 
  setPaused();
77
 
  return true;
78
 
}
79
 
 
80
 
unsigned int screentask::wake() {
81
 
  return last_report_time + report_freq;
82
 
}
83
 
 
84
 
void stattask::report() {
85
 
    if(dumpInFile) {
86
 
      main_scenario->stats->dumpData();
87
 
    }
88
 
    if (useCountf) {
89
 
      print_count_file(countf, 0);
90
 
    }
91
 
 
92
 
    main_scenario->stats->computeStat(CStat::E_RESET_PL_COUNTERS);
93
 
    last_dump_time = clock_tick;
94
 
}
95
 
 
96
 
bool stattask::run() {
97
 
  /* Statistics Logs. */
98
 
  if((getmilliseconds() - last_dump_time) >= report_freq_dumpLog)  {
99
 
    if (rate_increase) {
100
 
      rate += rate_increase;
101
 
      if (rate_max && (rate > rate_max)) {
102
 
        rate = rate_max;
103
 
        if (rate_quit) {
104
 
          quitting += 10;
105
 
        }
106
 
      }
107
 
      opentask::set_rate(rate);
108
 
    }
109
 
    report();
110
 
  }
111
 
  setPaused();
112
 
  return true;
113
 
}
114
 
 
115
 
unsigned int stattask::wake() {
116
 
  return last_dump_time + report_freq_dumpLog;
117
 
}