Deleted Added
sdiff udiff text old ( 8229:78bf55f23338 ) new ( 8235:6381dc8bcfcc )
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;

--- 18 unchanged lines hidden (view full) ---

27 *
28 * Authors: Nathan Binkert
29 */
30
31#include <iomanip>
32#include <iostream>
33#include <string>
34
35#include "base/cprintf.hh"
36#include "base/misc.hh"
37#include "base/statistics.hh"
38#include "base/types.hh"
39#include "sim/core.hh"
40#include "sim/stat_control.hh"
41
42// override the default main() code for this unittest
43const char *m5MainCommands[] = {
44 "import m5.stattestmain",
45 "m5.stattestmain.main()",
46 0 // sentinel is required
47};
48
49using namespace std;
50using namespace Stats;
51
52double
53testfunc()
54{
55 return 9.8;
56}
57
58class TestClass {
59 public:
60 double operator()() { return 9.7; }
61};
62
63struct StatTest
64{
65 Scalar s1;
66 Scalar s2;
67 Average s3;
68 Scalar s4;
69 Vector s5;
70 Distribution s6;
71 Vector s7;
72 AverageVector s8;

--- 21 unchanged lines hidden (view full) ---

94 Histogram h12;
95
96 Formula f1;
97 Formula f2;
98 Formula f3;
99 Formula f4;
100 Formula f5;
101
102 void run();
103 void init();
104};
105
106StatTest __stattest;
107void
108stattest_init()
109{
110 __stattest.init();
111}
112
113void
114stattest_run()
115{
116 __stattest.run();
117}
118
119void
120StatTest::init()
121{
122 cprintf("sizeof(Scalar) = %d\n", sizeof(Scalar));
123 cprintf("sizeof(Vector) = %d\n", sizeof(Vector));
124 cprintf("sizeof(Distribution) = %d\n", sizeof(Distribution));
125
126 s1
127 .name("Stat01")
128 .desc("this is statistic 1")
129 ;

--- 217 unchanged lines hidden (view full) ---

347
348
349 f1 = s1 + s2;
350 f2 = (-s1) / (-s2) * (-s3 + ULL(100) + s4);
351 f3 = sum(s5) * s7;
352 f4 += constant(10.0);
353 f4 += s5[3];
354 f5 = constant(1);
355}
356
357void
358StatTest::run()
359{
360 s16[1][0] = 1;
361 s16[0][1] = 3;
362 s16[0][0] = 2;
363 s16[1][1] = 9;
364 s16[1][1] += 9;
365 s16[1][8] += 8;
366 s16[1][7] += 7;
367 s16[1][6] += 6;

--- 250 unchanged lines hidden (view full) ---

618 h09.sample(i);
619 h10.sample(i);
620 }
621
622 for (int i = -1024; i <= 1023; i++) {
623 h11.sample(i);
624 h12.sample(i);
625 }
626}