"SfR Fresh" - the SfR Freeware/Shareware Archive 
Member "procinfo-ng-2.0.217/cygwin_rendercpupagestat.cpp" of archive procinfo-ng-2.0.217.tar.gz:
As a special service "SfR Fresh" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting with prefixed line numbers.
Alternatively you can here view or download the uninterpreted source code file.
That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
1 /*
2 This file is part of procinfo-NG
3
4 procinfo-NG is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; version 2.
7
8 procinfo-NG is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with procinfo-NG; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18 // uses renderPageStat and renderCPUstats to render both CPU and page stats
19 // returns a list of rows containing 2 columns.
20 /*vector< vector <string> > renderCPUandPageStats(bool perSecond, bool showTotals, const double &elapsed,
21 const uint64_t &CPUcount, const uint64_t &uptime, const vector <uint64_t> &cpuDiffs, const uint64_t &ctxtDiff, const vector <uint64_t> &pageDiffs)
22 */
23 vector< vector <string> > renderCPUandPageStats(bool perSecond, bool showTotals, const double elapsed,
24 const uint64_t CPUcount, const uint64_t uptime, const vector <uint64_t> cpuDiffs, const uint64_t ctxtDiff, const vector <uint64_t> pageDiffs)
25 {
26 vector< vector <string> > rows;
27 vector<string> row;
28 vector <string> names;
29
30 names.push_back(string("user :")); names.push_back(string("page in :"));
31 names.push_back(string(" ")); names.push_back(string("page out:"));
32 names.push_back(string("system:")); names.push_back(string("swap in :"));
33 names.push_back(string("idle :")); names.push_back(string("swap out:"));
34 names.push_back(string("uptime:")); names.push_back(string("context :"));
35
36 for(uint32_t i = 0; i <= 4; i++) {
37 uint64_t val = 0;
38 /*
39 * This abomination is b/c idle is shown near last
40 * but it's 3rd in line in /proc/stat
41 */
42 val = cpuDiffs[i];
43 if(i == 4) {
44 val = uptime;
45 }/* else if(i == 6) {
46 val = cpuDiffs[3];
47 } else if(i > 2) {
48 val = cpuDiffs[i+1];
49 }*/
50 vector<string> cols = renderCPUstat(perSecond, showTotals, elapsed, /*1*/ CPUcount, cpuDiffs[4],
51 val, names[i*2]);
52 row.push_back(cols[0]); row.push_back(cols[1]);
53
54 //#ifndef __CYGWIN__
55 cols = renderPageStat(perSecond, showTotals, elapsed,
56 ( i == 4 ? ctxtDiff : pageDiffs[i]), names[i*2+1]);
57 row.push_back(cols[0]); row.push_back(cols[1]);
58 //#endif
59
60 rows.push_back(row); row.clear();
61 }
62
63 return rows;
64 }