1 | <?php |
||||||
2 | // This file is part of BOINC. |
||||||
3 | // http://boinc.berkeley.edu |
||||||
4 | // Copyright (C) 2010 University of California |
||||||
5 | // |
||||||
6 | // BOINC is free software; you can redistribute it and/or modify it |
||||||
7 | // under the terms of the GNU Lesser General Public License |
||||||
8 | // as published by the Free Software Foundation, |
||||||
9 | // either version 3 of the License, or (at your option) any later version. |
||||||
10 | // |
||||||
11 | // BOINC is distributed in the hope that it will be useful, |
||||||
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||||
14 | // See the GNU Lesser General Public License for more details. |
||||||
15 | // |
||||||
16 | // You should have received a copy of the GNU Lesser General Public License |
||||||
17 | // along with BOINC. If not, see <http://www.gnu.org/licenses/>. |
||||||
18 | |||||||
19 | // utility for studying the credit system |
||||||
20 | |||||||
21 | error_reporting(E_ALL); |
||||||
22 | ini_set('display_errors', true); |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
23 | ini_set('display_startup_errors', true); |
||||||
24 | |||||||
25 | require_once("../inc/util.inc"); |
||||||
26 | require_once("../inc/util_ops.inc"); |
||||||
27 | require_once("../inc/boinc_db.inc"); |
||||||
28 | |||||||
29 | define('COBB_SCALE', 200/86400e9); |
||||||
30 | |||||||
31 | function gavid($avid, $appid) { |
||||||
32 | if ($avid < 0) { |
||||||
33 | return $appid*1000000 - $avid; |
||||||
34 | } |
||||||
35 | return $avid; |
||||||
36 | } |
||||||
37 | |||||||
38 | function show_res($r, $w) { |
||||||
39 | $gavid = gavid($r->app_version_id, $w->appid); |
||||||
40 | $hav = BoincHostAppVersion::lookup($r->hostid, $gavid); |
||||||
41 | $av = BoincAppVersion::lookup_id($r->app_version_id); |
||||||
42 | $raw_credit = $r->elapsed_time*$r->flops_estimate*COBB_SCALE; |
||||||
43 | echo "<hr><pre> |
||||||
44 | Result ID: <a href=db_action.php?table=result&id=$r->id>$r->id</a> |
||||||
45 | Host: <a href=credit.php?hostid=$r->hostid&avid=$r->app_version_id>$r->hostid</a> |
||||||
46 | elapsed_time: $r->elapsed_time |
||||||
47 | flops_estimate: ".$r->flops_estimate/1e9." |
||||||
48 | app_version_id: $r->app_version_id |
||||||
49 | "; |
||||||
50 | if ($av) { |
||||||
51 | $host_scale = $av->pfc_avg/$hav->pfc_avg; |
||||||
52 | $av_scale = $av->pfc_scale; |
||||||
53 | echo "app version scale: $av->pfc_scale\n"; |
||||||
54 | } else { |
||||||
55 | $host_scale = 1; |
||||||
56 | $av_scale = 1; |
||||||
57 | } |
||||||
58 | echo "host scale: $host_scale |
||||||
59 | Credit: |
||||||
60 | Original: $r->claimed_credit |
||||||
61 | Raw: $raw_credit |
||||||
62 | Scaled: ".$raw_credit*$host_scale*$av_scale." |
||||||
63 | Granted: $r->granted_credit |
||||||
64 | "; |
||||||
65 | if ($hav) { |
||||||
66 | echo "Host app version: |
||||||
67 | PFC avg: $hav->pfc_avg |
||||||
68 | "; |
||||||
69 | } |
||||||
70 | } |
||||||
71 | |||||||
72 | function handle_result($resultid) { |
||||||
73 | $r = BoincResult::lookup_id($resultid); |
||||||
74 | $w = BoincWorkunit::lookup_id($r->workunitid); |
||||||
75 | $rs = BoincResult::enum("workunitid=$r->workunitid and validate_state=1"); |
||||||
76 | $app_version_ids = array(); |
||||||
77 | foreach ($rs as $r) { |
||||||
78 | show_res($r, $w); |
||||||
79 | $app_version_ids[] = $r->app_version_id; |
||||||
80 | } |
||||||
81 | $app_version_ids = array_unique($app_version_ids); |
||||||
82 | foreach ($app_version_ids as $avid) { |
||||||
83 | show_av($avid); |
||||||
84 | } |
||||||
85 | } |
||||||
86 | |||||||
87 | function show_host_av($host_id, $av_id) { |
||||||
88 | $hav = BoincHostAppVersion::lookup("host_id=$host_id and app_version_id=$av_id"); |
||||||
0 ignored issues
–
show
The call to
BoincHostAppVersion::lookup() has too few arguments starting with app_version_id .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. ![]() |
|||||||
89 | page_head("Host $host_id / app_version $av_id credit"); |
||||||
90 | echo "Results"; |
||||||
91 | $rs = BoincResult::enum("hostid=$host_id and app_version_id=$av_id and validate_state=1 order by id desc limit 100"); |
||||||
92 | start_table(); |
||||||
93 | table_header("Workunit", "Elapsed", "Proj FLOPS", "Raw credit", "granted"); |
||||||
94 | $n = 0; |
||||||
95 | $total=0; |
||||||
96 | foreach($rs as $r) { |
||||||
97 | $raw_credit = $r->elapsed_time*$r->flops_estimate*COBB_SCALE; |
||||||
98 | $n++; |
||||||
99 | $total += $raw_credit; |
||||||
100 | table_row( |
||||||
101 | "<a href=credit.php?wu_id=$r->workunitid>$r->workunitid</a>", |
||||||
102 | $r->elapsed_time, |
||||||
103 | $r->projected_flops, |
||||||
104 | $raw_credit, |
||||||
105 | $r->granted_credit |
||||||
106 | ); |
||||||
107 | } |
||||||
108 | |||||||
109 | start_table(); |
||||||
110 | row2("PFC nsamples", $hav->pfc_n); |
||||||
111 | row2("PFC avg", $hav->pfc_avg); |
||||||
112 | row2("Average raw credit", $total/$n); |
||||||
113 | end_table(); |
||||||
114 | |||||||
115 | page_tail(); |
||||||
116 | } |
||||||
117 | |||||||
118 | function av_string($av_id) { |
||||||
119 | if ($av_id> 0) { |
||||||
120 | $av = BoincAppVersion::lookup($av_id); |
||||||
121 | $plat = BoincPlatform::lookup_id($av->platformid); |
||||||
122 | $x = "<a href=credit.php?av_id=$av_id>$plat->name $av->plan_class</a>"; |
||||||
123 | } else { |
||||||
124 | $x = "Anonymous platform"; |
||||||
125 | } |
||||||
126 | return $x; |
||||||
127 | } |
||||||
128 | |||||||
129 | function show_wu($wu_id) { |
||||||
130 | page_head("Workunit credit"); |
||||||
131 | $wu = BoincWorkunit::lookup_id($wu_id); |
||||||
132 | $app = BoincApp::lookup_id($wu->appid); |
||||||
133 | start_table(); |
||||||
134 | row2("App", "<a href=credit.php?app_id=$app->id>$app->user_friendly_name</a>"); |
||||||
135 | end_table(); |
||||||
136 | echo "Results"; |
||||||
137 | start_table(); |
||||||
138 | table_header("Host", "App version", "Elapsed", "FLOPS est"); |
||||||
139 | $results = BoincResult::enum("workunitid=$wu->id and validate_state=1"); |
||||||
140 | foreach ($results as $r) { |
||||||
141 | table_row( |
||||||
142 | "<a href=credit.php?host_id=$r->hostid>$r->hostid</a>", |
||||||
143 | av_string($r->app_version_id), |
||||||
144 | $r->elapsed_time, |
||||||
145 | $r->flops_estimate |
||||||
146 | ); |
||||||
147 | } |
||||||
148 | end_table(); |
||||||
149 | page_tail(); |
||||||
150 | } |
||||||
151 | |||||||
152 | function show_av($av_id) { |
||||||
153 | $av = BoincAppVersion::lookup_id($av_id); |
||||||
154 | $app = BoincApp::lookup_id($av->appid); |
||||||
155 | $plat = BoincPlatform::lookup_id($av->platformid); |
||||||
156 | $av_desc = "$plat->name $av->plan_class"; |
||||||
157 | page_head("App version $av_desc credit"); |
||||||
158 | |||||||
159 | start_table(); |
||||||
160 | row2("PFC samples", $av->pfc_n); |
||||||
161 | row2("PFC average", $av->pfc_avg); |
||||||
162 | row2("PFC scale", $av->pfc_scale); |
||||||
163 | row2("App", $app->user_friendly_name); |
||||||
164 | end_table(); |
||||||
165 | |||||||
166 | $results = BoincResult::enum("app_version_id=$av_id and validate_state=1"); |
||||||
167 | start_table(); |
||||||
168 | table_header("Host/App_version", "Elapsed", "FLOPS est"); |
||||||
169 | foreach ($results as $r) { |
||||||
170 | $avs = av_string($r->app_version_id); |
||||||
171 | table_row( |
||||||
172 | "<a href=credit.php?host_id=$r->hostid&a_id=$r->app_version_id> host $r->hostid AV $avs</a>", |
||||||
173 | $r->elapsed_time, |
||||||
174 | $r->flops_estimate |
||||||
175 | ); |
||||||
176 | } |
||||||
177 | end_table(); |
||||||
178 | page_tail(); |
||||||
179 | } |
||||||
180 | |||||||
181 | function show_appl($app_id) { |
||||||
182 | $app = BoincApp::lookup_id($app_id); |
||||||
183 | page_head("App $app->user_friendly_name credit"); |
||||||
184 | $avs = BoincAppVersion::enum("appid=$app_id and deprecated=0"); |
||||||
185 | start_table(); |
||||||
186 | table_header("platform/class/version", "PFC nsamples", "PFC avg", "PFC scale"); |
||||||
187 | $avs = current_versions($avs); |
||||||
188 | foreach ($avs as $av) { |
||||||
189 | $plat = BoincPlatform::lookup_id($av->platformid); |
||||||
190 | table_row( |
||||||
191 | "<a href=credit.php?av_id=$av->id>$plat->user_friendly_name $av->plan_class $av->version_num</a>", |
||||||
192 | $av->pfc_n, |
||||||
193 | $av->pfc_avg, |
||||||
194 | $av->pfc_scale |
||||||
195 | ); |
||||||
196 | } |
||||||
197 | end_table(); |
||||||
198 | page_tail(); |
||||||
199 | } |
||||||
200 | |||||||
201 | $wu_id = get_int("wu_id", true); |
||||||
202 | $host_id = get_int("host_id", true); |
||||||
203 | $av_id = get_int("av_id", true); |
||||||
204 | $app_id = get_int("app_id", true); |
||||||
205 | if ($wu_id) { |
||||||
206 | show_wu($wu_id); |
||||||
207 | exit; |
||||||
208 | } |
||||||
209 | if ($host_id && $av_id) { |
||||||
210 | show_host_av($host_id, $av_id); |
||||||
211 | exit; |
||||||
212 | } |
||||||
213 | if ($av_id) { |
||||||
214 | show_av($av_id); |
||||||
215 | exit; |
||||||
216 | } |
||||||
217 | if ($app_id) { |
||||||
218 | show_appl($app_id); |
||||||
219 | exit; |
||||||
220 | } |
||||||
221 | |||||||
222 | error_page("no command"); |
||||||
223 | |||||||
224 | ?> |
||||||
225 |