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