Deleted Added
sdiff udiff text old ( 2665:a124942bacb8 ) new ( 2716:b9114064d77a )
full compact
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Nathan Binkert
29 */
30
31#include <iomanip>
32#include <iostream>
33#include <fstream>
34#include <string>
35#include <unistd.h>
36
37#include "base/cprintf.hh"
38#include "base/misc.hh"
39#include "base/statistics.hh"
40#include "base/stats/text.hh"
41#include "base/stats/mysql.hh"
42#include "sim/host.hh"
43
44using namespace std;
45using namespace Stats;
46
47Tick curTick = 0;
48Tick ticksPerSecond = ULL(2000000000);
49
50Scalar<> s1;
51Scalar<> s2;
52Average<> s3;
53Scalar<> s4;
54Vector<> s5;
55Distribution<> s6;
56Vector<> s7;
57AverageVector<> s8;
58StandardDeviation<> s9;
59AverageDeviation<> s10;
60Scalar<> s11;
61Distribution<> s12;
62VectorDistribution<> s13;
63VectorStandardDeviation<> s14;
64VectorAverageDeviation<> s15;
65Vector2d<> s16;
66
67Formula f1;
68Formula f2;
69Formula f3;
70Value f4;
71Value f5;
72Formula f6;
73Formula f7;
74
75ostream *outputStream = &cout;
76
77double
78testfunc()
79{
80 return 9.8;
81}
82
83class TestClass {
84 public:
85 double operator()() { return 9.7; }
86};
87
88char *progname = "";
89
90void
91usage()
92{
93 panic("incorrect usage.\n"
94 "usage:\n"
95 "\t%s [-t [-c] [-d]]\n", progname);
96}
97
98int
99main(int argc, char *argv[])
100{
101 bool descriptions = false;
102 bool compat = false;
103 bool text = false;
104 string mysql_name;
105 string mysql_host;
106 string mysql_user = "binkertn";
107 string mysql_passwd;
108
109 char c;
110 progname = argv[0];
111 while ((c = getopt(argc, argv, "cdh:P:p:s:tu:")) != -1) {
112 switch (c) {
113 case 'c':
114 compat = true;
115 break;
116 case 'd':
117 descriptions = true;
118 break;
119 case 'h':
120 mysql_host = optarg;
121 break;
122 case 'P':
123 mysql_passwd = optarg;
124 break;
125 case 's':
126 mysql_name = optarg;
127 break;
128 case 't':
129 text = true;
130 break;
131 case 'u':
132 mysql_user = optarg;
133 break;
134 default:
135 usage();
136 }
137 }
138
139 if (!text && (compat || descriptions))
140 usage();
141
142 s5.init(5);
143 s6.init(1, 100, 13);
144 s7.init(7);
145 s8.init(10);
146 s12.init(1, 100, 13);
147 s13.init(4, 0, 99, 10);
148 s14.init(9);
149 s15.init(10);
150 s16.init(2, 9);
151
152 s1
153 .name("Stat01")
154 .desc("this is statistic 1")
155 ;
156
157 s2
158 .name("Stat02")
159 .desc("this is statistic 2")
160 .prereq(s11)
161 ;
162
163 s3
164 .name("Stat03")
165 .desc("this is statistic 3")
166 .prereq(f7)
167 ;
168
169 s4
170 .name("Stat04")
171 .desc("this is statistic 4")
172 .prereq(s11)
173 ;
174
175 s5
176 .name("Stat05")
177 .desc("this is statistic 5")
178 .prereq(s11)
179 .subname(0, "foo1")
180 .subname(1, "foo2")
181 .subname(2, "foo3")
182 .subname(3, "foo4")
183 .subname(4, "foo5")
184 ;
185
186 s6
187 .name("Stat06")
188 .desc("this is statistic 6")
189 .prereq(s11)
190 ;
191
192 s7
193 .name("Stat07")
194 .desc("this is statistic 7")
195 .precision(1)
196 .flags(pdf | total)
197 .prereq(s11)
198 ;
199
200 s8
201 .name("Stat08")
202 .desc("this is statistic 8")
203 .precision(2)
204 .prereq(s11)
205 .subname(4, "blarg")
206 ;
207
208 s9
209 .name("Stat09")
210 .desc("this is statistic 9")
211 .precision(4)
212 .prereq(s11)
213 ;
214
215 s10
216 .name("Stat10")
217 .desc("this is statistic 10")
218 .prereq(s11)
219 ;
220
221 s12
222 .name("Stat12")
223 .desc("this is statistic 12")
224 ;
225
226 s13
227 .name("Stat13")
228 .desc("this is statistic 13")
229 ;
230
231 s14
232 .name("Stat14")
233 .desc("this is statistic 14")
234 ;
235
236 s15
237 .name("Stat15")
238 .desc("this is statistic 15")
239 ;
240
241 s16
242 .name("Stat16")
243 .desc("this is statistic 16")
244 .flags(total)
245 .subname(0, "sub0")
246 .subname(1, "sub1")
247 .ysubname(0, "y0")
248 .ysubname(1, "y1")
249 ;
250
251 f1
252 .name("Formula1")
253 .desc("this is formula 1")
254 .prereq(s11)
255 ;
256
257 f2
258 .name("Formula2")
259 .desc("this is formula 2")
260 .prereq(s11)
261 .precision(1)
262 ;
263
264 f3
265 .name("Formula3")
266 .desc("this is formula 3")
267 .prereq(s11)
268 .subname(0, "bar1")
269 .subname(1, "bar2")
270 .subname(2, "bar3")
271 .subname(3, "bar4")
272 .subname(4, "bar5")
273 ;
274
275 f4
276 .functor(testfunc)
277 .name("Formula4")
278 .desc("this is formula 4")
279 ;
280
281 TestClass testclass;
282 f5
283 .functor(testclass)
284 .name("Formula5")
285 .desc("this is formula 5")
286 ;
287
288 f6
289 .name("Formula6")
290 .desc("this is formula 6")
291 ;
292
293 f1 = s1 + s2;
294 f2 = (-s1) / (-s2) * (-s3 + ULL(100) + s4);
295 f3 = sum(s5) * s7;
296 f6 += constant(10.0);
297 f6 += s5[3];
298 f7 = constant(1);
299
300 check();
301 reset();
302
303 s16[1][0] = 1;
304 s16[0][1] = 3;
305 s16[0][0] = 2;
306 s16[1][1] = 9;
307 s16[1][1] += 9;
308 s16[1][8] += 8;
309 s16[1][7] += 7;
310 s16[1][6] += 6;
311 s16[1][5] += 5;
312 s16[1][4] += 4;
313
314 s11 = 1;
315 s3 = 9;
316 s8[3] = 9;
317 s15[0].sample(1234);
318 s15[1].sample(1234);
319 s15[2].sample(1234);
320 s15[3].sample(1234);
321 s15[4].sample(1234);
322 s15[5].sample(1234);
323 s15[6].sample(1234);
324 s15[7].sample(1234);
325 s15[8].sample(1234);
326 s15[9].sample(1234);
327
328 s10.sample(1000000000);
329 curTick += ULL(1000000);
330 s10.sample(100000);
331 s10.sample(100000);
332 s10.sample(100000);
333 s10.sample(100000);
334 s10.sample(100000);
335 s10.sample(100000);
336 s10.sample(100000);
337 s10.sample(100000);
338 s10.sample(100000);
339 s10.sample(100000);
340 s10.sample(100000);
341 s10.sample(100000);
342 s10.sample(100000);
343 s13[0].sample(12);
344 s13[1].sample(29);
345 s13[2].sample(12);
346 s13[3].sample(29);
347 s13[0].sample(42);
348 s13[1].sample(29);
349 s13[2].sample(42);
350 s13[3].sample(32);
351 s13[0].sample(52);
352 s13[1].sample(49);
353 s13[2].sample(42);
354 s13[3].sample(25);
355 s13[0].sample(32);
356 s13[1].sample(49);
357 s13[2].sample(22);
358 s13[3].sample(49);
359 s13[0].sample(62);
360 s13[1].sample(99);
361 s13[2].sample(72);
362 s13[3].sample(23);
363 s13[0].sample(52);
364 s13[1].sample(78);
365 s13[2].sample(69);
366 s13[3].sample(49);
367
368 s14[0].sample(1234);
369 s14[1].sample(4134);
370 s14[4].sample(1213);
371 s14[3].sample(1124);
372 s14[2].sample(1243);
373 s14[7].sample(1244);
374 s14[4].sample(7234);
375 s14[2].sample(9234);
376 s14[3].sample(1764);
377 s14[7].sample(1564);
378 s14[3].sample(3234);
379 s14[1].sample(2234);
380 s14[5].sample(1234);
381 s14[2].sample(4334);
382 s14[2].sample(1234);
383 s14[4].sample(4334);
384 s14[6].sample(1234);
385 s14[8].sample(8734);
386 s14[1].sample(5234);
387 s14[3].sample(8234);
388 s14[7].sample(5234);
389 s14[4].sample(4434);
390 s14[3].sample(7234);
391 s14[2].sample(1934);
392 s14[1].sample(9234);
393 s14[5].sample(5634);
394 s14[3].sample(1264);
395 s14[7].sample(5223);
396 s14[0].sample(1234);
397 s14[0].sample(5434);
398 s14[3].sample(8634);
399 s14[1].sample(1234);
400
401
402 s15[0].sample(1234);
403 s15[1].sample(4134);
404 curTick += ULL(1000000);
405 s15[4].sample(1213);
406 curTick += ULL(1000000);
407 s15[3].sample(1124);
408 curTick += ULL(1000000);
409 s15[2].sample(1243);
410 curTick += ULL(1000000);
411 s15[7].sample(1244);
412 curTick += ULL(1000000);
413 s15[4].sample(7234);
414 s15[2].sample(9234);
415 s15[3].sample(1764);
416 s15[7].sample(1564);
417 s15[3].sample(3234);
418 s15[1].sample(2234);
419 curTick += ULL(1000000);
420 s15[5].sample(1234);
421 curTick += ULL(1000000);
422 s15[9].sample(4334);
423 curTick += ULL(1000000);
424 s15[2].sample(1234);
425 curTick += ULL(1000000);
426 s15[4].sample(4334);
427 s15[6].sample(1234);
428 curTick += ULL(1000000);
429 s15[8].sample(8734);
430 curTick += ULL(1000000);
431 s15[1].sample(5234);
432 curTick += ULL(1000000);
433 s15[3].sample(8234);
434 curTick += ULL(1000000);
435 s15[7].sample(5234);
436 s15[4].sample(4434);
437 s15[3].sample(7234);
438 s15[2].sample(1934);
439 s15[1].sample(9234);
440 curTick += ULL(1000000);
441 s15[5].sample(5634);
442 s15[3].sample(1264);
443 s15[7].sample(5223);
444 s15[0].sample(1234);
445 s15[0].sample(5434);
446 s15[3].sample(8634);
447 curTick += ULL(1000000);
448 s15[1].sample(1234);
449
450 s4 = curTick;
451
452 s8[3] = 99999;
453
454 s3 = 12;
455 s3++;
456 curTick += 9;
457
458 s1 = 9;
459 s1 += 9;
460 s1 -= 11;
461 s1++;
462 ++s1;
463 s1--;
464 --s1;
465
466 s2 = 9;
467
468 s5[0] += 1;
469 s5[1] += 2;
470 s5[2] += 3;
471 s5[3] += 4;
472 s5[4] += 5;
473
474 s7[0] = 10;
475 s7[1] = 20;
476 s7[2] = 30;
477 s7[3] = 40;
478 s7[4] = 50;
479 s7[5] = 60;
480 s7[6] = 70;
481
482 s6.sample(0);
483 s6.sample(1);
484 s6.sample(2);
485 s6.sample(3);
486 s6.sample(4);
487 s6.sample(5);
488 s6.sample(6);
489 s6.sample(7);
490 s6.sample(8);
491 s6.sample(9);
492
493 s6.sample(10);
494 s6.sample(10);
495 s6.sample(10);
496 s6.sample(10);
497 s6.sample(10);
498 s6.sample(10);
499 s6.sample(10);
500 s6.sample(10);
501 s6.sample(11);
502 s6.sample(19);
503 s6.sample(20);
504 s6.sample(20);
505 s6.sample(21);
506 s6.sample(21);
507 s6.sample(31);
508 s6.sample(98);
509 s6.sample(99);
510 s6.sample(99);
511 s6.sample(99);
512
513 s7[0] = 700;
514 s7[1] = 600;
515 s7[2] = 500;
516 s7[3] = 400;
517 s7[4] = 300;
518 s7[5] = 200;
519 s7[6] = 100;
520
521 s9.sample(100);
522 s9.sample(100);
523 s9.sample(100);
524 s9.sample(100);
525 s9.sample(10);
526 s9.sample(10);
527 s9.sample(10);
528 s9.sample(10);
529 s9.sample(10);
530
531 curTick += 9;
532 s4 = curTick;
533 s6.sample(100);
534 s6.sample(100);
535 s6.sample(100);
536 s6.sample(101);
537 s6.sample(102);
538
539 s12.sample(100);
540
541 if (text) {
542 Text out(cout);
543 out.descriptions = descriptions;
544 out.compat = compat;
545 out();
546 }
547
548 if (!mysql_name.empty()) {
549 MySql out;
550 out.connect(mysql_host, mysql_user, mysql_passwd, "m5stats",
551 mysql_name, "test");
552 out();
553 }
554
555 return 0;
556}