gem5  v21.0.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
storage.test.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 Daniel R. Carvalho
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 <gtest/gtest-spi.h>
30 #include <gtest/gtest.h>
31 
32 #include <cmath>
33 
35 #include "base/stats/storage.hh"
36 
37 // Instantiate the fake class to have a valid curTick of 0
38 GTestTickHandler tickHandler;
39 
41 void increaseTick() { tickHandler.setCurTick(curTick() + 1); }
42 
45 {
48 
50  : value(value), numSamples(num_samples)
51  {
52  }
53 };
54 
60 class MockInfo : public Stats::Info
61 {
62  public:
63  MockInfo(Stats::StorageParams* storage_params)
64  : Stats::Info()
65  {
66  this->storageParams = storage_params;
67  }
68  ~MockInfo() = default;
69 
70  bool check() const override { return true; }
71  void prepare() override { }
72  void reset() override { }
73  bool zero() const override { return true; }
74  void visit(Stats::Output &visitor) override { }
75 };
76 
78 TEST(StatsStatStorTest, SetValueResult)
79 {
80  Stats::StatStor stor(nullptr);
82 
83  val = 10;
84  stor.set(val);
85  ASSERT_EQ(stor.value(), val);
86  ASSERT_EQ(stor.result(), Stats::Result(val));
87 
88  val = 1234;
89  stor.set(val);
90  ASSERT_EQ(stor.value(), val);
91  ASSERT_EQ(stor.result(), Stats::Result(val));
92 }
93 
95 TEST(StatsStatStorTest, Prepare)
96 {
97  Stats::StatStor stor(nullptr);
99 
100  val = 10;
101  stor.set(val);
102  stor.prepare(nullptr);
103  ASSERT_EQ(stor.value(), val);
104  ASSERT_EQ(stor.result(), Stats::Result(val));
105 }
106 
108 TEST(StatsStatStorTest, IncDec)
109 {
110  Stats::StatStor stor(nullptr);
111  Stats::Counter diff_val = 10;
112  Stats::Counter val = 0;
113 
114  stor.inc(diff_val);
115  val += diff_val;
116  ASSERT_EQ(stor.value(), val);
117 
118  stor.inc(diff_val);
119  val += diff_val;
120  ASSERT_EQ(stor.value(), val);
121 
122  stor.dec(diff_val);
123  val -= diff_val;
124  ASSERT_EQ(stor.value(), val);
125 
126  stor.dec(diff_val);
127  val -= diff_val;
128  ASSERT_EQ(stor.value(), val);
129 }
130 
136 TEST(StatsStatStorTest, ZeroReset)
137 {
138  Stats::StatStor stor(nullptr);
139  Stats::Counter val = 10;
140 
141  ASSERT_TRUE(stor.zero());
142 
143  stor.reset(nullptr);
144  ASSERT_TRUE(stor.zero());
145 
146  stor.reset(nullptr);
147  stor.inc(val);
148  ASSERT_FALSE(stor.zero());
149 }
150 
152 TEST(StatsAvgStorTest, SetValueResult)
153 {
154  Stats::AvgStor stor(nullptr);
156  Stats::Result total = 0;
157  Tick last_reset = 0;
158  Tick last_tick = 0;
159 
160  val = 10;
161  stor.set(val);
162  last_tick = curTick();
163  ASSERT_EQ(stor.value(), val);
164  ASSERT_EQ(stor.result(), Stats::Result(total + val) /
165  Stats::Result(curTick() - last_reset + 1));
166  increaseTick();
167 
168  total += val * (curTick() - last_tick);
169  val = 1234;
170  stor.set(val);
171  last_tick = curTick();
172  ASSERT_EQ(stor.value(), val);
173  ASSERT_EQ(stor.result(), Stats::Result(total + val) /
174  Stats::Result(curTick() - last_reset + 1));
175  increaseTick();
176 }
177 
178 #if TRACING_ON
179 
182 TEST(StatsAvgStorDeathTest, Result)
183 {
184  Stats::AvgStor stor(nullptr);
185  increaseTick();
186  ASSERT_DEATH(stor.result(), ".+");
187 }
188 #endif
189 
194 TEST(StatsAvgStorTest, Prepare)
195 {
196  Stats::AvgStor stor(nullptr);
197  Stats::Counter val = 10;
198  Stats::Result total = 0;
199  Tick last_reset = 0;
200  Tick last_tick = 0;
201 
202  val = 10;
203  stor.set(val);
204  last_tick = curTick();
205  ASSERT_EQ(stor.value(), val);
206  ASSERT_EQ(stor.result(), Stats::Result(total + val) /
207  Stats::Result(curTick() - last_reset + 1));
208  increaseTick();
209 
210  total += val * (curTick() - last_tick);
211  stor.prepare(nullptr);
212  last_tick = curTick();
213  ASSERT_EQ(stor.value(), val);
214  ASSERT_EQ(stor.result(), Stats::Result(total + val) /
215  Stats::Result(curTick() - last_reset + 1));
216  increaseTick();
217 }
218 
220 TEST(StatsAvgStorTest, IncDec)
221 {
222  Stats::AvgStor stor(nullptr);
223  Stats::Counter diff_val = 10;
224  Stats::Counter val = 0;
225 
226  stor.set(diff_val);
227  val += diff_val;
228  ASSERT_EQ(stor.value(), val);
229 
230  stor.inc(diff_val);
231  val += diff_val;
232  ASSERT_EQ(stor.value(), val);
233 
234  stor.inc(diff_val);
235  val += diff_val;
236  ASSERT_EQ(stor.value(), val);
237 
238  stor.dec(diff_val);
239  val -= diff_val;
240  ASSERT_EQ(stor.value(), val);
241 
242  stor.dec(diff_val);
243  val -= diff_val;
244  ASSERT_EQ(stor.value(), val);
245 }
246 
252 TEST(StatsAvgStorTest, ZeroReset)
253 {
254  Stats::AvgStor stor(nullptr);
255  Stats::Counter val = 10;
256 
257  ASSERT_TRUE(stor.zero());
258 
259  stor.reset(nullptr);
260  ASSERT_TRUE(stor.zero());
261 
262  // Set current value to val, reset total and increase tick, so that the
263  // next call to set will update the total to be different from zero
264  stor.inc(val);
265  stor.reset(nullptr);
266  increaseTick();
267  stor.inc(val);
268  ASSERT_FALSE(stor.zero());
269 }
270 
271 #if TRACING_ON
272 
273 TEST(StatsDistStorDeathTest, BucketSize0)
274 {
275  testing::internal::CaptureStderr();
276  EXPECT_ANY_THROW(Stats::DistStor::Params params(0, 5, 0));
277  testing::internal::GetCapturedStderr();
278 }
279 #endif
280 
286 TEST(StatsDistStorTest, ZeroReset)
287 {
288  Stats::DistStor::Params params(0, 99, 10);
289  MockInfo info(&params);
290  Stats::DistStor stor(&info);
291  Stats::Counter val = 10;
292  Stats::Counter num_samples = 5;
293 
294  ASSERT_TRUE(stor.zero());
295 
296  stor.reset(&info);
297  stor.sample(val, num_samples);
298  ASSERT_FALSE(stor.zero());
299 
300  stor.reset(&info);
301  ASSERT_TRUE(stor.zero());
302 }
303 
308 TEST(StatsDistStorTest, Size)
309 {
310  Stats::Counter val = 10;
311  Stats::Counter num_samples = 5;
312  Stats::Counter size = 20;
314 
315  Stats::DistStor::Params params(0, 19, 1);
316  MockInfo info(&params);
317  Stats::DistStor stor(&info);
318 
319  ASSERT_EQ(stor.size(), size);
320  stor.sample(val, num_samples);
321  ASSERT_EQ(stor.size(), size);
322  stor.prepare(&info, data);
323  ASSERT_EQ(stor.size(), size);
324  stor.reset(&info);
325  ASSERT_EQ(stor.size(), size);
326  stor.zero();
327  ASSERT_EQ(stor.size(), size);
328 }
329 
337 void
339  const Stats::DistData& expected_data, bool no_log = true)
340 {
341  ASSERT_EQ(data.type, expected_data.type);
342  ASSERT_EQ(data.min, expected_data.min);
343  ASSERT_EQ(data.max, expected_data.max);
344  ASSERT_EQ(data.bucket_size, expected_data.bucket_size);
345  ASSERT_EQ(data.min_val, expected_data.min_val);
346  ASSERT_EQ(data.max_val, expected_data.max_val);
347  ASSERT_EQ(data.sum, expected_data.sum);
348  ASSERT_EQ(data.squares, expected_data.squares);
349  if (!no_log) {
350  ASSERT_EQ(data.logs, expected_data.logs);
351  }
352  ASSERT_EQ(data.samples, expected_data.samples);
353  ASSERT_EQ(data.cvec.size(), expected_data.cvec.size());
354  for (int i = 0; i < expected_data.cvec.size(); i++) {
355  ASSERT_EQ(data.cvec[i], expected_data.cvec[i]);
356  }
357 }
358 
369 void
371  int num_values, Stats::DistData& expected_data)
372 {
373  MockInfo info(&params);
374  Stats::DistStor stor(&info);
375 
378 
379  expected_data.min = params.min;
380  expected_data.max = params.max;
381  expected_data.sum = 0;
382  expected_data.squares = 0;
383  expected_data.logs = 0;
384  expected_data.samples = 0;
385 
386  // Populate storage with more data
387  for (int i = 0; i < num_values; i++) {
388  stor.sample(values[i].value, values[i].numSamples);
389 
390  val = values[i].value * values[i].numSamples;
391  expected_data.sum += val;
392  expected_data.squares += values[i].value * val;
393  expected_data.samples += values[i].numSamples;
394  }
395  stor.prepare(&info, data);
396 
397  // DistStor does not use log
398  checkExpectedDistData(data, expected_data, true);
399 }
400 
402 TEST(StatsDistStorTest, SamplePrepareSingle)
403 {
404  Stats::DistStor::Params params(0, 99, 5);
405 
406  ValueSamples values[] = {{10, 5}};
407  int num_values = sizeof(values) / sizeof(ValueSamples);
408 
409  // Setup expected data
410  Stats::DistData expected_data;
411  expected_data.type = Stats::Dist;
412  expected_data.bucket_size = params.bucket_size;
413  expected_data.underflow = 0;
414  expected_data.overflow = 0;
415  expected_data.min_val = 10;
416  expected_data.max_val = 10;
417  expected_data.cvec.clear();
418  expected_data.cvec.resize(params.buckets);
419  expected_data.cvec[2] = 5;
420 
421  prepareCheckDistStor(params, values, num_values, expected_data);
422 }
423 
425 TEST(StatsDistStorTest, SamplePrepareMultiple)
426 {
427  Stats::DistStor::Params params(0, 99, 5);
428 
429  // There are 20 buckets: [0,5[, [5,10[, [10,15[, ..., [95,100[.
430  // We test that values that pass the maximum bucket value (1234, 12345678,
431  // 100) are added to the overflow counter, and that the ones below the
432  // minimum bucket value (-10, -1) are added to the underflow counter.
433  // The extremes (0 and 99) are added to check if they go to the first and
434  // last buckets.
435  ValueSamples values[] = {{10, 5}, {1234, 2}, {12345678, 99}, {-10, 4},
436  {17, 17}, {52, 63}, {18, 11}, {0, 1}, {99, 15}, {-1, 200}, {100, 50}};
437  int num_values = sizeof(values) / sizeof(ValueSamples);
438 
439  // Setup variables that should always match params' values
440  Stats::DistData expected_data;
441  expected_data.type = Stats::Dist;
442  expected_data.min_val = -10;
443  expected_data.max_val = 12345678;
444  expected_data.bucket_size = params.bucket_size;
445  expected_data.underflow = 204;
446  expected_data.overflow = 151;
447  expected_data.sum = 0;
448  expected_data.squares = 0;
449  expected_data.samples = 0;
450  expected_data.cvec.clear();
451  expected_data.cvec.resize(params.buckets);
452  expected_data.cvec[0] = 1;
453  expected_data.cvec[2] = 5;
454  expected_data.cvec[3] = 17+11;
455  expected_data.cvec[10] = 63;
456  expected_data.cvec[19] = 15;
457 
458  prepareCheckDistStor(params, values, num_values, expected_data);
459 }
460 
462 TEST(StatsDistStorTest, Reset)
463 {
464  Stats::DistStor::Params params(0, 99, 5);
465  MockInfo info(&params);
466  Stats::DistStor stor(&info);
467 
468  // Populate storage with random samples
469  ValueSamples values[] = {{10, 5}, {1234, 2}, {12345678, 99}, {-10, 4},
470  {17, 17}, {52, 63}, {18, 11}, {0, 1}, {99, 15}, {-1, 200}, {100, 50}};
471  int num_values = sizeof(values) / sizeof(ValueSamples);
472  for (int i = 0; i < num_values; i++) {
473  stor.sample(values[i].value, values[i].numSamples);
474  }
475 
476  // Reset storage, and make sure all data has been cleared
477  stor.reset(&info);
479  stor.prepare(&info, data);
480 
481  Stats::DistData expected_data;
482  expected_data.type = Stats::Dist;
483  expected_data.bucket_size = params.bucket_size;
484  expected_data.underflow = 0;
485  expected_data.overflow = 0;
486  expected_data.min = params.min;
487  expected_data.max = params.max;
488  expected_data.min_val = 0;
489  expected_data.max_val = 0;
490  expected_data.sum = 0;
491  expected_data.squares = 0;
492  expected_data.samples = 0;
493  expected_data.cvec.clear();
494  expected_data.cvec.resize(params.buckets);
495 
496  checkExpectedDistData(data, expected_data, true);
497 }
498 
499 #if TRACING_ON
500 
501 TEST(StatsHistStorDeathTest, NotEnoughBuckets0)
502 {
503  testing::internal::CaptureStderr();
504  EXPECT_ANY_THROW(Stats::HistStor::Params params(0));
505  testing::internal::GetCapturedStderr();
506 }
507 
509 TEST(StatsHistStorDeathTest, NotEnoughBuckets1)
510 {
511  testing::internal::CaptureStderr();
512  EXPECT_ANY_THROW(Stats::HistStor::Params params(1));
513  testing::internal::GetCapturedStderr();
514 }
515 #endif
516 
522 TEST(StatsHistStorTest, ZeroReset)
523 {
524  Stats::HistStor::Params params(10);
525  MockInfo info(&params);
526  Stats::HistStor stor(&info);
527  Stats::Counter val = 10;
528  Stats::Counter num_samples = 5;
529 
530  ASSERT_TRUE(stor.zero());
531 
532  stor.reset(&info);
533  stor.sample(val, num_samples);
534  ASSERT_FALSE(stor.zero());
535 
536  stor.reset(&info);
537  ASSERT_TRUE(stor.zero());
538 }
539 
544 TEST(StatsHistStorTest, Size)
545 {
546  Stats::Counter val = 10;
547  Stats::Counter num_samples = 5;
549  Stats::size_type sizes[] = {2, 10, 1234};
550 
551  for (int i = 0; i < (sizeof(sizes) / sizeof(Stats::size_type)); i++) {
552  Stats::HistStor::Params params(sizes[i]);
553  MockInfo info(&params);
554  Stats::HistStor stor(&info);
555 
556  ASSERT_EQ(stor.size(), sizes[i]);
557  stor.sample(val, num_samples);
558  ASSERT_EQ(stor.size(), sizes[i]);
559  stor.prepare(&info, data);
560  ASSERT_EQ(stor.size(), sizes[i]);
561  stor.reset(&info);
562  ASSERT_EQ(stor.size(), sizes[i]);
563  stor.zero();
564  ASSERT_EQ(stor.size(), sizes[i]);
565  }
566 }
567 
578 void
580  int num_values, Stats::DistData& expected_data)
581 {
582  MockInfo info(&params);
583  Stats::HistStor stor(&info);
584 
587  bool no_log = false;
588 
589  expected_data.min_val = expected_data.min;
590  expected_data.max = expected_data.max_val + expected_data.bucket_size - 1;
591  expected_data.sum = 0;
592  expected_data.squares = 0;
593  expected_data.logs = 0;
594  expected_data.samples = 0;
595 
596  // Populate storage with more data
597  for (int i = 0; i < num_values; i++) {
598  stor.sample(values[i].value, values[i].numSamples);
599 
600  val = values[i].value * values[i].numSamples;
601  expected_data.sum += val;
602  expected_data.squares += values[i].value * val;
603  if (values[i].value < 0) {
604  // Negative values don't have log, so mark log check to be skipped
605  no_log = true;
606  } else {
607  expected_data.logs +=
608  std::log(values[i].value) * values[i].numSamples;
609  }
610  expected_data.samples += values[i].numSamples;
611  }
612  stor.prepare(&info, data);
613  checkExpectedDistData(data, expected_data, no_log);
614 }
615 
620 TEST(StatsHistStorTest, SamplePrepareFit)
621 {
622  Stats::HistStor::Params params(4);
623 
624  // Setup expected data for the hand-carved values given. The final buckets
625  // will be divided at:
626  // Bkt0=[0,1[ , Bkt1=[1,2[, Bkt2=[2,3[, Bkt3=[3,4[
627  ValueSamples values[] = {{0, 5}, {1, 2}, {2, 99}, {3, 4}};
628  const int num_values = sizeof(values) / sizeof(ValueSamples);
629  Stats::DistData expected_data;
630  expected_data.type = Stats::Hist;
631  expected_data.bucket_size = 1;
632  expected_data.min = 0;
633  expected_data.max_val = 3;
634  expected_data.cvec.clear();
635  expected_data.cvec.resize(params.buckets);
636  expected_data.cvec[0] = 5;
637  expected_data.cvec[1] = 2;
638  expected_data.cvec[2] = 99;
639  expected_data.cvec[3] = 4;
640 
641  prepareCheckHistStor(params, values, num_values, expected_data);
642 }
643 
648 TEST(StatsHistStorTest, SamplePrepareSingleGrowUp)
649 {
650  Stats::HistStor::Params params(4);
651 
652  // Setup expected data for the hand-carved values given. Since there
653  // are four buckets, and the highest value is 4, the bucket size will
654  // grow to be 2. The final buckets will be divided at:
655  // Bkt0=[0,2[ , Bkt1=[2,4[, Bkt2=[4,6[, Bkt3=[6,8[
656  ValueSamples values[] = {{0, 5}, {1, 2}, {2, 99}, {4, 4}};
657  const int num_values = sizeof(values) / sizeof(ValueSamples);
658  Stats::DistData expected_data;
659  expected_data.type = Stats::Hist;
660  expected_data.bucket_size = 2;
661  expected_data.min = 0;
662  expected_data.max_val = 6;
663  expected_data.cvec.clear();
664  expected_data.cvec.resize(params.buckets);
665  expected_data.cvec[0] = 5+2;
666  expected_data.cvec[1] = 99;
667  expected_data.cvec[2] = 4;
668  expected_data.cvec[3] = 0;
669 
670  prepareCheckHistStor(params, values, num_values, expected_data);
671 }
672 
677 TEST(StatsHistStorTest, SamplePrepareMultipleGrowUp)
678 {
679  Stats::HistStor::Params params(4);
680 
681  // Setup expected data for the hand-carved values given. Since there
682  // are four buckets, and the highest value is 4, the bucket size will
683  // grow thrice to become 8. The final buckets will be divided at:
684  // Bkt0=[0,8[ , Bkt1=[8,16[, Bkt2=[16,24[, Bkt3=[24,32[
685  ValueSamples values[] = {{0, 5}, {1, 2}, {2, 99}, {16, 4}};
686  const int num_values = sizeof(values) / sizeof(ValueSamples);
687  Stats::DistData expected_data;
688  expected_data.type = Stats::Hist;
689  expected_data.bucket_size = 8;
690  expected_data.min = 0;
691  expected_data.max_val = 24;
692  expected_data.cvec.clear();
693  expected_data.cvec.resize(params.buckets);
694  expected_data.cvec[0] = 5+2+99;
695  expected_data.cvec[1] = 0;
696  expected_data.cvec[2] = 4;
697  expected_data.cvec[3] = 0;
698 
699  prepareCheckHistStor(params, values, num_values, expected_data);
700 }
701 
707 TEST(StatsHistStorTest, SamplePrepareGrowDownOddBuckets)
708 {
709  Stats::HistStor::Params params(5);
710 
711  // Setup expected data for the hand-carved values given. Since there
712  // is a negative value, the min bucket will change, and the bucket size
713  // will grow to be 2. The final buckets will be divided at:
714  // Bkt0=[-4,-2[ , Bkt1=[-2,-0[, Bkt2=[0,2[, Bkt3=[2,4[, Bkt4=[4,6[
715  ValueSamples values[] =
716  {{0, 5}, {1, 2}, {2, 99}, {3, 12}, {4, 33}, {-1, 4}};
717  const int num_values = sizeof(values) / sizeof(ValueSamples);
718  Stats::DistData expected_data;
719  expected_data.type = Stats::Hist;
720  expected_data.bucket_size = 2;
721  expected_data.min = -4;
722  expected_data.max_val = 4;
723  expected_data.cvec.clear();
724  expected_data.cvec.resize(params.buckets);
725  expected_data.cvec[0] = 0;
726  expected_data.cvec[1] = 4;
727  expected_data.cvec[2] = 5+2;
728  expected_data.cvec[3] = 99+12;
729  expected_data.cvec[4] = 33;
730 
731  prepareCheckHistStor(params, values, num_values, expected_data);
732 }
733 
739 TEST(StatsHistStorTest, SamplePrepareGrowDownEvenBuckets)
740 {
741  Stats::HistStor::Params params(4);
742 
743  // Setup expected data for the hand-carved values given. Since there
744  // is a negative value, the min bucket will change, and the bucket size
745  // will grow to be 2. The final buckets will be divided at:
746  // Bkt0=[-4,-2[ , Bkt1=[-2,0[, Bkt2=[0,2[, Bkt3=[2,4[
747  ValueSamples values[] = {{0, 5}, {1, 2}, {2, 99}, {-1, 4}};
748  const int num_values = sizeof(values) / sizeof(ValueSamples);
749  Stats::DistData expected_data;
750  expected_data.type = Stats::Hist;
751  expected_data.bucket_size = 2;
752  expected_data.min = -4;
753  expected_data.max_val = 2;
754  expected_data.cvec.clear();
755  expected_data.cvec.resize(params.buckets);
756  expected_data.cvec[0] = 0;
757  expected_data.cvec[1] = 4;
758  expected_data.cvec[2] = 5+2;
759  expected_data.cvec[3] = 99;
760 
761  prepareCheckHistStor(params, values, num_values, expected_data);
762 }
763 
769 TEST(StatsHistStorTest, SamplePrepareGrowDownGrowOutOddBuckets)
770 {
771  Stats::HistStor::Params params(5);
772 
773  // Setup expected data for the hand-carved values given. Since there
774  // is a negative value, the min bucket will change, and the bucket size
775  // will grow to be 8. The final buckets will be divided at:
776  // Bkt0=[-16,-8[ , Bkt1=[-8,0[, Bkt2=[0,8[, Bkt3=[8,16[, Bkt4=[16,24[
777  ValueSamples values[] =
778  {{0, 5}, {1, 2}, {2, 99}, {3, 12}, {4, 33}, {-12, 4}};
779  const int num_values = sizeof(values) / sizeof(ValueSamples);
780  Stats::DistData expected_data;
781  expected_data.type = Stats::Hist;
782  expected_data.bucket_size = 8;
783  expected_data.min = -16;
784  expected_data.max_val = 16;
785  expected_data.cvec.clear();
786  expected_data.cvec.resize(params.buckets);
787  expected_data.cvec[0] = 4;
788  expected_data.cvec[1] = 0;
789  expected_data.cvec[2] = 5+2+99+12+33;
790  expected_data.cvec[3] = 0;
791  expected_data.cvec[4] = 0;
792 
793  prepareCheckHistStor(params, values, num_values, expected_data);
794 }
795 
801 TEST(StatsHistStorTest, SamplePrepareGrowDownGrowOutEvenBuckets)
802 {
803  Stats::HistStor::Params params(4);
804 
805  // Setup expected data for the hand-carved values given. Since there
806  // is a negative value, the min bucket will change, and the bucket size
807  // will grow to be 8. The final buckets will be divided at:
808  // Bkt0=[-16,-8[ , Bkt1=[-8,0[, Bkt2=[0,8[, Bkt3=[8,16[
809  ValueSamples values[] =
810  {{0, 5}, {1, 2}, {2, 99}, {3, 12}, {-12, 4}};
811  const int num_values = sizeof(values) / sizeof(ValueSamples);
812  Stats::DistData expected_data;
813  expected_data.type = Stats::Hist;
814  expected_data.bucket_size = 8;
815  expected_data.min = -16;
816  expected_data.max_val = 8;
817  expected_data.cvec.clear();
818  expected_data.cvec.resize(params.buckets);
819  expected_data.cvec[0] = 4;
820  expected_data.cvec[1] = 0;
821  expected_data.cvec[2] = 5+2+99+12;
822  expected_data.cvec[3] = 0;
823 
824  prepareCheckHistStor(params, values, num_values, expected_data);
825 }
826 
832 TEST(StatsHistStorTest, SamplePrepareMultipleGrowOddBuckets)
833 {
834  Stats::HistStor::Params params(5);
835 
836  // Setup expected data for the hand-carved values given. This adds quite
837  // a few positive and negative samples, and the bucket size will grow to
838  // be 64. The final buckets will be divided at:
839  // Bkt0=[-128,-64[ , Bkt1=[-64,0[, Bkt2=[0,64[, Bkt3=[64,128[,
840  // Bkt4=[128,192[
841  ValueSamples values[] =
842  {{0, 5}, {7, 2}, {31, 99}, {-8, 12}, {127, 4}, {-120, 53}, {-50, 1}};
843  const int num_values = sizeof(values) / sizeof(ValueSamples);
844  Stats::DistData expected_data;
845  expected_data.type = Stats::Hist;
846  expected_data.bucket_size = 64;
847  expected_data.min = -128;
848  expected_data.max_val = 128;
849  expected_data.cvec.clear();
850  expected_data.cvec.resize(params.buckets);
851  expected_data.cvec[0] = 53;
852  expected_data.cvec[1] = 12+1;
853  expected_data.cvec[2] = 5+2+99;
854  expected_data.cvec[3] = 4;
855  expected_data.cvec[4] = 0;
856 
857  prepareCheckHistStor(params, values, num_values, expected_data);
858 }
859 
865 TEST(StatsHistStorTest, SamplePrepareMultipleGrowEvenBuckets)
866 {
867  Stats::HistStor::Params params(4);
868 
869  // Setup expected data for the hand-carved values given. This adds quite
870  // a few positive and negative samples, and the bucket size will grow to
871  // be 64. The final buckets will be divided at:
872  // Bkt0=[-128,-64[ , Bkt1=[-64,0[, Bkt2=[0,64[, Bkt3=[64,128[
873  ValueSamples values[] =
874  {{0, 5}, {7, 2}, {31, 99}, {-8, 12}, {127, 4}, {-120, 53}, {-50, 1}};
875  const int num_values = sizeof(values) / sizeof(ValueSamples);
876  Stats::DistData expected_data;
877  expected_data.type = Stats::Hist;
878  expected_data.bucket_size = 64;
879  expected_data.min = -128;
880  expected_data.max_val = 64;
881  expected_data.cvec.clear();
882  expected_data.cvec.resize(params.buckets);
883  expected_data.cvec[0] = 53;
884  expected_data.cvec[1] = 12+1;
885  expected_data.cvec[2] = 5+2+99;
886  expected_data.cvec[3] = 4;
887 
888  prepareCheckHistStor(params, values, num_values, expected_data);
889 }
890 
892 TEST(StatsHistStorTest, Reset)
893 {
894  Stats::HistStor::Params params(4);
895  MockInfo info(&params);
896  Stats::HistStor stor(&info);
897 
898  // Setup expected data for the hand-carved values given. This adds quite
899  // a few positive and negative samples, and the bucket size will grow to
900  // be 64. The final buckets will be divided at:
901  // Bkt0=[-128,-64[ , Bkt1=[-64,0[, Bkt2=[0,64[, Bkt3=[64,128[
902  ValueSamples values[] =
903  {{0, 5}, {7, 2}, {31, 99}, {-8, 12}, {127, 4}, {-120, 53}, {-50, 1}};
904  const int num_values = sizeof(values) / sizeof(ValueSamples);
905  for (int i = 0; i < num_values; i++) {
906  stor.sample(values[i].value, values[i].numSamples);
907  }
908 
909  // Reset storage, and make sure all data has been cleared:
910  // Bkt0=[0,1[ , Bkt1=[1,2[, Bkt2=[2,3[, Bkt3=[3,4[
911  stor.reset(&info);
912  Stats::DistData expected_data;
913  expected_data.type = Stats::Hist;
914  expected_data.bucket_size = 1;
915  expected_data.min = 0;
916  expected_data.max_val = 3;
917  expected_data.cvec.clear();
918  expected_data.cvec.resize(params.buckets);
919  prepareCheckHistStor(params, values, 0, expected_data);
920 }
921 
922 #if TRACING_ON
923 
924 TEST(StatsHistStorDeathTest, AddDifferentSize)
925 {
926  Stats::HistStor::Params params(4);
927  MockInfo info(&params);
928  Stats::HistStor stor(&info);
929 
930  Stats::HistStor::Params params2(5);
931  MockInfo info2(&params2);
932  Stats::HistStor stor2(&info2);
933 
934  ASSERT_DEATH(stor.add(&stor2), ".+");
935 }
936 
938 TEST(StatsHistStorDeathTest, AddDifferentMin)
939 {
940  Stats::HistStor::Params params(4);
941  MockInfo info(&params);
942  Stats::HistStor stor(&info);
943  stor.sample(-1, 3);
944 
945  // On creation, the storage's min is zero
946  Stats::HistStor::Params params2(4);
947  MockInfo info2(&params2);
948  Stats::HistStor stor2(&info2);
949 
950  ASSERT_DEATH(stor.add(&stor2), ".+");
951 }
952 #endif
953 
955 TEST(StatsHistStorTest, Add)
956 {
957  Stats::HistStor::Params params(4);
958  MockInfo info(&params);
959 
960  // Setup first storage. Buckets are:
961  // Bkt0=[0,16[, Bkt1=[16,32[, Bkt2=[32,48[, Bkt3=[58,64[
962  Stats::HistStor stor(&info);
963  ValueSamples values[] = {{0, 5}, {3, 2}, {20, 37}, {32, 18}};
964  int num_values = sizeof(values) / sizeof(ValueSamples);
965  for (int i = 0; i < num_values; i++) {
966  stor.sample(values[i].value, values[i].numSamples);
967  }
969  stor.prepare(&info, data);
970 
971  // Setup second storage. Buckets are:
972  // Bkt0=[0,32[, Bkt1=[32,64[, Bkt2=[64,96[, Bkt3=[96,128[
973  Stats::HistStor stor2(&info);
974  ValueSamples values2[] = {{10, 10}, {0, 1}, {80, 4}, {17, 100}, {95, 79}};
975  int num_values2 = sizeof(values2) / sizeof(ValueSamples);
976  for (int i = 0; i < num_values2; i++) {
977  stor2.sample(values2[i].value, values2[i].numSamples);
978  }
979  Stats::DistData data2;
980  stor2.prepare(&info, data2);
981 
982  // Perform the merge
983  stor.add(&stor2);
984  Stats::DistData merge_data;
985  stor.prepare(&info, merge_data);
986 
987  // Setup expected data. Buckets are:
988  // Bkt0=[0,32[, Bkt1=[32,64[, Bkt2=[64,96[, Bkt3=[96,128[
989  Stats::DistData expected_data;
990  expected_data.type = Stats::Hist;
991  expected_data.bucket_size = 32;
992  expected_data.min = 0;
993  expected_data.max = 127;
994  expected_data.min_val = 0;
995  expected_data.max_val = 96;
996  expected_data.cvec.clear();
997  expected_data.cvec.resize(params.buckets);
998  expected_data.cvec[0] = 5+2+37+10+1+100;
999  expected_data.cvec[1] = 18;
1000  expected_data.cvec[2] = 4+79;
1001  expected_data.cvec[3] = 0;
1002  expected_data.sum = data.sum + data2.sum;
1003  expected_data.squares = data.squares + data2.squares;
1004  expected_data.logs = data.squares + data2.logs;
1005  expected_data.samples = data.samples + data2.samples;
1006 
1007  // Compare results
1008  checkExpectedDistData(merge_data, expected_data, false);
1009 }
1010 
1016 TEST(StatsSampleStorTest, ZeroReset)
1017 {
1018  Stats::SampleStor stor(nullptr);
1019  Stats::Counter val = 10;
1020  Stats::Counter num_samples = 5;
1021 
1022  ASSERT_TRUE(stor.zero());
1023 
1024  stor.reset(nullptr);
1025  stor.sample(val, num_samples);
1026  ASSERT_FALSE(stor.zero());
1027 
1028  stor.reset(nullptr);
1029  ASSERT_TRUE(stor.zero());
1030 }
1031 
1033 TEST(StatsSampleStorTest, SamplePrepare)
1034 {
1035  Stats::SampleStor stor(nullptr);
1036  ValueSamples values[] = {{10, 5}, {1234, 2}, {0xFFFFFFFF, 18}};
1037  int num_values = sizeof(values) / sizeof(ValueSamples);
1040  Stats::DistData expected_data;
1042  MockInfo info(&params);
1043 
1044  // Simple test with one value being sampled
1045  stor.sample(values[0].value, values[0].numSamples);
1046  stor.prepare(&info, data);
1047  val = values[0].value * values[0].numSamples;
1048  expected_data.type = Stats::Deviation;
1049  expected_data.sum = val;
1050  expected_data.squares = values[0].value * val;
1051  expected_data.samples = values[0].numSamples;
1052  ASSERT_EQ(data.type, expected_data.type);
1053  ASSERT_EQ(data.sum, expected_data.sum);
1054  ASSERT_EQ(data.squares, expected_data.squares);
1055  ASSERT_EQ(data.samples, expected_data.samples);
1056 
1057  // Reset storage, and make sure all data has been cleared
1058  expected_data.sum = 0;
1059  expected_data.squares = 0;
1060  expected_data.samples = 0;
1061  stor.reset(nullptr);
1062  stor.prepare(&info, data);
1063  ASSERT_EQ(data.type, expected_data.type);
1064  ASSERT_EQ(data.sum, expected_data.sum);
1065  ASSERT_EQ(data.squares, expected_data.squares);
1066  ASSERT_EQ(data.samples, expected_data.samples);
1067 
1068  // Populate storage with more data
1069  for (int i = 0; i < num_values; i++) {
1070  stor.sample(values[i].value, values[i].numSamples);
1071 
1072  val = values[i].value * values[i].numSamples;
1073  expected_data.sum += val;
1074  expected_data.squares += values[i].value * val;
1075  expected_data.samples += values[i].numSamples;
1076  }
1077  stor.prepare(&info, data);
1078  ASSERT_EQ(data.type, expected_data.type);
1079  ASSERT_EQ(data.sum, expected_data.sum);
1080  ASSERT_EQ(data.squares, expected_data.squares);
1081  ASSERT_EQ(data.samples, expected_data.samples);
1082 }
1083 
1085 TEST(StatsSampleStorTest, Size)
1086 {
1087  Stats::SampleStor stor(nullptr);
1088  Stats::Counter val = 10;
1089  Stats::Counter num_samples = 5;
1092  MockInfo info(&params);
1093 
1094  ASSERT_EQ(stor.size(), 1);
1095  stor.sample(val, num_samples);
1096  ASSERT_EQ(stor.size(), 1);
1097  stor.prepare(&info, data);
1098  ASSERT_EQ(stor.size(), 1);
1099  stor.reset(nullptr);
1100  ASSERT_EQ(stor.size(), 1);
1101  stor.zero();
1102  ASSERT_EQ(stor.size(), 1);
1103 }
1104 
1110 TEST(StatsAvgSampleStorTest, ZeroReset)
1111 {
1112  Stats::AvgSampleStor stor(nullptr);
1113  Stats::Counter val = 10;
1114  Stats::Counter num_samples = 5;
1115 
1116  ASSERT_TRUE(stor.zero());
1117 
1118  stor.reset(nullptr);
1119  stor.sample(val, num_samples);
1120  ASSERT_FALSE(stor.zero());
1121 
1122  stor.reset(nullptr);
1123  ASSERT_TRUE(stor.zero());
1124 }
1125 
1127 TEST(StatsAvgSampleStorTest, SamplePrepare)
1128 {
1129  Stats::AvgSampleStor stor(nullptr);
1130  ValueSamples values[] = {{10, 5}, {1234, 2}, {0xFFFFFFFF, 18}};
1131  int num_values = sizeof(values) / sizeof(ValueSamples);
1134  Stats::DistData expected_data;
1136  MockInfo info(&params);
1137 
1138  // Simple test with one value being sampled
1139  stor.sample(values[0].value, values[0].numSamples);
1140  stor.prepare(&info, data);
1141  val = values[0].value * values[0].numSamples;
1142  expected_data.type = Stats::Deviation;
1143  expected_data.sum = val;
1144  expected_data.squares = values[0].value * val;
1145  ASSERT_EQ(data.type, expected_data.type);
1146  ASSERT_EQ(data.sum, expected_data.sum);
1147  ASSERT_EQ(data.squares, expected_data.squares);
1148  ASSERT_EQ(data.samples, curTick());
1149 
1150  increaseTick();
1151 
1152  // Reset storage, and make sure all data has been cleared
1153  expected_data.sum = 0;
1154  expected_data.squares = 0;
1155  stor.reset(nullptr);
1156  stor.prepare(&info, data);
1157  ASSERT_EQ(data.type, expected_data.type);
1158  ASSERT_EQ(data.sum, expected_data.sum);
1159  ASSERT_EQ(data.squares, expected_data.squares);
1160  ASSERT_EQ(data.samples, curTick());
1161 
1162  increaseTick();
1163 
1164  // Populate storage with more data
1165  for (int i = 0; i < num_values; i++) {
1166  stor.sample(values[i].value, values[i].numSamples);
1167 
1168  val = values[i].value * values[i].numSamples;
1169  expected_data.sum += val;
1170  expected_data.squares += values[i].value * val;
1171  }
1172  stor.prepare(&info, data);
1173  ASSERT_EQ(data.type, expected_data.type);
1174  ASSERT_EQ(data.sum, expected_data.sum);
1175  ASSERT_EQ(data.squares, expected_data.squares);
1176  ASSERT_EQ(data.samples, curTick());
1177 }
1178 
1180 TEST(StatsAvgSampleStorTest, Size)
1181 {
1182  Stats::AvgSampleStor stor(nullptr);
1183  Stats::Counter val = 10;
1184  Stats::Counter num_samples = 5;
1187  MockInfo info(&params);
1188 
1189  ASSERT_EQ(stor.size(), 1);
1190  stor.sample(val, num_samples);
1191  ASSERT_EQ(stor.size(), 1);
1192  stor.prepare(&info, data);
1193  ASSERT_EQ(stor.size(), 1);
1194  stor.reset(nullptr);
1195  ASSERT_EQ(stor.size(), 1);
1196  stor.zero();
1197  ASSERT_EQ(stor.size(), 1);
1198 }
1199 
1205 TEST(StatsSparseHistStorTest, ZeroReset)
1206 {
1207  Stats::SparseHistStor stor(nullptr);
1208  Stats::Counter val = 10;
1209  Stats::Counter num_samples = 5;
1210 
1211  ASSERT_TRUE(stor.zero());
1212 
1213  stor.reset(nullptr);
1214  stor.sample(val, num_samples);
1215  ASSERT_FALSE(stor.zero());
1216 
1217  stor.reset(nullptr);
1218  ASSERT_TRUE(stor.zero());
1219 }
1220 
1222 TEST(StatsSparseHistStorTest, SamplePrepare)
1223 {
1224  Stats::SparseHistStor stor(nullptr);
1225  ValueSamples values[] = {{10, 5}, {1234, 2}, {0xFFFFFFFF, 18}};
1226  int num_values = sizeof(values) / sizeof(ValueSamples);
1227  Stats::Counter total_samples;
1229 
1230  // Simple test with one value being sampled
1231  stor.sample(values[0].value, values[0].numSamples);
1232  stor.prepare(nullptr, data);
1233  ASSERT_EQ(stor.size(), 1);
1234  ASSERT_EQ(data.cmap.size(), 1);
1235  ASSERT_EQ(data.cmap[values[0].value], values[0].numSamples);
1236  ASSERT_EQ(data.samples, values[0].numSamples);
1237 
1238  // Reset storage, and make sure all data has been cleared
1239  stor.reset(nullptr);
1240  stor.prepare(nullptr, data);
1241  ASSERT_EQ(stor.size(), 0);
1242  ASSERT_EQ(data.cmap.size(), 0);
1243  ASSERT_EQ(data.samples, 0);
1244 
1245  // Populate storage with more data
1246  for (int i = 0; i < num_values; i++) {
1247  stor.sample(values[i].value, values[i].numSamples);
1248  }
1249  stor.prepare(nullptr, data);
1250  total_samples = 0;
1251  ASSERT_EQ(stor.size(), num_values);
1252  ASSERT_EQ(data.cmap.size(), num_values);
1253  for (int i = 0; i < num_values; i++) {
1254  ASSERT_EQ(data.cmap[values[i].value], values[i].numSamples);
1255  total_samples += values[i].numSamples;
1256  }
1257  ASSERT_EQ(data.samples, total_samples);
1258 }
Stats::Deviation
@ Deviation
Definition: info.hh:176
Stats::AvgStor::reset
void reset(Info *info)
Reset stat value to default.
Definition: storage.hh:206
Stats::AvgStor::dec
void dec(Counter val)
Deccrement the current count by the provided value, calls set.
Definition: storage.hh:168
Stats::SampleStor::zero
bool zero() const
Return true if no samples have been added.
Definition: storage.hh:604
data
const char data[]
Definition: circlebuf.test.cc:47
Stats::AvgStor::prepare
void prepare(Info *info)
Prepare stat data for dumping or serialization.
Definition: storage.hh:196
Stats::SparseHistData
Data structure of sparse histogram.
Definition: info.hh:247
Stats::DistStor::Params::min
Counter min
The minimum value to track.
Definition: storage.hh:261
Stats::AvgStor
Templatized storage and interface to a per-tick average stat.
Definition: storage.hh:123
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
Stats::HistStor
Templatized storage and interface for a histogram stat.
Definition: storage.hh:395
Stats::HistStor::Params::buckets
size_type buckets
The number of buckets.
Definition: storage.hh:459
Stats::AvgStor::result
Result result() const
Return the current average.
Definition: storage.hh:181
Stats::DistData::sum
Counter sum
Definition: info.hh:190
Stats::DistData::type
DistType type
Definition: info.hh:180
Stats::DistStor::size
size_type size() const
Return the number of buckets in this distribution.
Definition: storage.hh:301
Stats::DistData::samples
Counter samples
Definition: info.hh:193
Stats::SampleStor::reset
void reset(Info *info)
Reset stat value to default.
Definition: storage.hh:622
Stats::SampleStor::size
size_type size() const
Return the number of entries in this stat, 1.
Definition: storage.hh:598
Stats::HistStor::Params
The parameters for a distribution stat.
Definition: storage.hh:456
MockInfo
A mocked info class.
Definition: storage.test.cc:60
Stats::Info::Info
Info()
Definition: info.cc:68
Stats::AvgSampleStor::Params
Definition: storage.hh:643
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:59
ValueSamples::numSamples
Stats::Counter numSamples
Definition: storage.test.cc:47
MockInfo::~MockInfo
~MockInfo()=default
Stats::DistStor::prepare
void prepare(Info *info, DistData &data)
Definition: storage.hh:314
Stats::SampleStor::Params
Definition: storage.hh:567
Stats::Hist
@ Hist
Definition: info.hh:176
Stats::AvgStor::zero
bool zero() const
Definition: storage.hh:190
Stats::DistData::underflow
Counter underflow
Definition: info.hh:187
Stats::DistStor::Params::max
Counter max
The maximum value to track.
Definition: storage.hh:263
Stats::AvgStor::value
Counter value() const
Return the current count.
Definition: storage.hh:174
Stats::Dist
@ Dist
Definition: info.hh:176
Stats::DistStor
Templatized storage and interface for a distribution stat.
Definition: storage.hh:229
storage.hh
Stats::SampleStor::prepare
void prepare(Info *info, DistData &data)
Definition: storage.hh:607
Stats::StorageParams
Definition: storage.hh:45
Stats::Info::storageParams
const StorageParams * storageParams
Definition: info.hh:95
Stats::AvgSampleStor::reset
void reset(Info *info)
Reset stat value to default.
Definition: storage.hh:696
Stats::DistData::logs
Counter logs
Definition: info.hh:192
MockInfo::reset
void reset() override
Reset the stat to the default state.
Definition: storage.test.cc:72
increaseTick
void increaseTick()
Increases the current tick by one.
Definition: storage.test.cc:41
ValueSamples::ValueSamples
ValueSamples(Stats::Counter value, Stats::Counter num_samples)
Definition: storage.test.cc:49
Stats::DistData::min_val
Counter min_val
Definition: info.hh:185
Stats::DistStor::Params
The parameters for a distribution stat.
Definition: storage.hh:258
Stats::DistData::min
Counter min
Definition: info.hh:181
Stats::DistData::bucket_size
Counter bucket_size
Definition: info.hh:183
Stats::DistData
Definition: info.hh:178
Stats::DistStor::sample
void sample(Counter val, int number)
Add a value to the distribution for the given number of times.
Definition: storage.cc:49
Stats::StatStor::zero
bool zero() const
Definition: storage.hh:113
TEST
TEST(StatsStatStorTest, SetValueResult)
Test setting and getting a value to the storage.
Definition: storage.test.cc:78
Stats::AvgSampleStor::prepare
void prepare(Info *info, DistData &data)
Definition: storage.hh:681
prepareCheckDistStor
void prepareCheckDistStor(Stats::DistStor::Params &params, ValueSamples *values, int num_values, Stats::DistData &expected_data)
Auxiliary function that finishes preparing the DistStor's expected values, perform the calls to the s...
Definition: storage.test.cc:370
Stats::HistStor::zero
bool zero() const
Returns true if any calls to sample have been made.
Definition: storage.hh:500
Stats::SparseHistStor
Templatized storage and interface for a sparse histogram stat.
Definition: storage.hh:710
Stats::DistData::squares
Counter squares
Definition: info.hh:191
Stats::DistStor::reset
void reset(Info *info)
Reset stat value to default.
Definition: storage.hh:342
Stats::AvgSampleStor
Templatized storage for distribution that calculates per tick mean and variance.
Definition: storage.hh:634
Stats::AvgSampleStor::size
size_type size() const
Return the number of entries, in this case 1.
Definition: storage.hh:672
Stats::Output
Definition: output.hh:58
X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:769
Stats::SampleStor
Templatized storage and interface for a distribution that calculates mean and variance.
Definition: storage.hh:556
Stats::StatStor::dec
void dec(Counter val)
Decrement the stat by the given value.
Definition: storage.hh:86
Stats::StatStor::reset
void reset(Info *info)
Reset stat value to default.
Definition: storage.hh:108
Stats::Info
Definition: info.hh:70
Stats::Result
double Result
All results are doubles.
Definition: types.hh:50
Stats::StatStor::inc
void inc(Counter val)
Increment the stat by the given value.
Definition: storage.hh:80
tickHandler
GTestTickHandler tickHandler
Definition: storage.test.cc:38
Stats::Counter
double Counter
All counters are of 64-bit values.
Definition: types.hh:41
Stats::DistStor::zero
bool zero() const
Returns true if any calls to sample have been made.
Definition: storage.hh:308
Stats::StatStor
Templatized storage and interface for a simple scalar stat.
Definition: storage.hh:53
Stats::AvgStor::inc
void inc(Counter val)
Increment the current count by the provided value, calls set.
Definition: storage.hh:162
Stats::HistStor::add
void add(HistStor *other)
Adds the contents of the given storage to this storage.
Definition: storage.cc:205
MockInfo::zero
bool zero() const override
Definition: storage.test.cc:73
Stats::StatStor::result
Result result() const
Return the value of this stat as a result type.
Definition: storage.hh:98
Stats::SparseHistStor::sample
void sample(Counter val, int number)
Add a value to the distribution for the given number of times.
Definition: storage.hh:736
Stats::SparseHistStor::zero
bool zero() const
Returns true if any calls to sample have been made.
Definition: storage.hh:753
checkExpectedDistData
void checkExpectedDistData(const Stats::DistData &data, const Stats::DistData &expected_data, bool no_log=true)
Compare both dist datas to see if their contents match.
Definition: storage.test.cc:338
Stats::StatStor::prepare
void prepare(Info *info)
Prepare stat data for dumping or serialization.
Definition: storage.hh:103
ValueSamples
A pair of value and its number of samples, used for sampling.
Definition: storage.test.cc:44
MockInfo::check
bool check() const override
Check that this stat has been set up properly and is ready for use.
Definition: storage.test.cc:70
Stats::DistData::max
Counter max
Definition: info.hh:182
Stats::StatStor::set
void set(Counter val)
The the stat to the given value.
Definition: storage.hh:74
Stats::DistData::overflow
Counter overflow
Definition: info.hh:188
prepareCheckHistStor
void prepareCheckHistStor(Stats::HistStor::Params &params, ValueSamples *values, int num_values, Stats::DistData &expected_data)
Auxiliary function that finishes preparing the HistStor's expected values, perform the calls to the s...
Definition: storage.test.cc:579
Stats
Definition: statistics.cc:53
ValueSamples::value
Stats::Counter value
Definition: storage.test.cc:46
curTick
Tick curTick()
The universal simulation clock.
Definition: cur_tick.hh:43
Stats::size_type
unsigned int size_type
Definition: types.hh:54
Stats::HistStor::size
size_type size() const
Return the number of buckets in this distribution.
Definition: storage.hh:493
cur_tick_fake.hh
Stats::StatStor::value
Counter value() const
Return the value of this stat as its base type.
Definition: storage.hh:92
Ps2::Reset
@ Reset
Definition: types.hh:63
Stats::HistStor::prepare
void prepare(Info *info, DistData &data)
Definition: storage.hh:506
Stats::total
const FlagsType total
Print the total.
Definition: info.hh:50
Stats::SparseHistStor::size
size_type size() const
Return the number of buckets in this distribution.
Definition: storage.hh:746
Stats::SparseHistStor::prepare
void prepare(Info *info, SparseHistData &data)
Definition: storage.hh:759
Stats::HistStor::sample
void sample(Counter val, int number)
Add a value to the distribution for the given number of times.
Definition: storage.cc:172
Stats::DistData::max_val
Counter max_val
Definition: info.hh:186
Stats::HistStor::reset
void reset(Info *info)
Reset stat value to default.
Definition: storage.hh:534
Stats::AvgStor::set
void set(Counter val)
Set the current count to the one provided, update the total and last set values.
Definition: storage.hh:151
MockInfo::MockInfo
MockInfo(Stats::StorageParams *storage_params)
Definition: storage.test.cc:63
Stats::SparseHistStor::reset
void reset(Info *info)
Reset stat value to default.
Definition: storage.hh:774
Stats::SampleStor::sample
void sample(Counter val, int number)
Add a value the given number of times to this running average.
Definition: storage.hh:587
Stats::DistStor::Params::bucket_size
Counter bucket_size
The number of entries in each bucket.
Definition: storage.hh:265
Stats::AvgSampleStor::zero
bool zero() const
Return true if no samples have been added.
Definition: storage.hh:678
MockInfo::visit
void visit(Stats::Output &visitor) override
Visitor entry for outputing statistics data.
Definition: storage.test.cc:74
Stats::DistStor::Params::buckets
size_type buckets
The number of buckets.
Definition: storage.hh:267
Stats::DistData::cvec
VCounter cvec
Definition: info.hh:189
MockInfo::prepare
void prepare() override
Prepare the stat for dumping.
Definition: storage.test.cc:71
Stats::AvgSampleStor::sample
void sample(Counter val, int number)
Add a value to the distribution for the given number of times.
Definition: storage.hh:662

Generated on Tue Jun 22 2021 15:28:25 for gem5 by doxygen 1.8.17