diff options
| author | Volodymyr Sapsai <vsapsai@apple.com> | 2019-10-11 00:57:41 +0000 |
|---|---|---|
| committer | Volodymyr Sapsai <vsapsai@apple.com> | 2019-10-11 00:57:41 +0000 |
| commit | adb203feda9036d39ffecc21f5a9c463a20ef115 (patch) | |
| tree | 74f6fc9a05e55a1fd253c743813439b323b732a0 /llvm/unittests | |
| parent | 63835f3ac7672a6f1c32109f303a849b6c044b39 (diff) | |
| download | bcm5719-llvm-adb203feda9036d39ffecc21f5a9c463a20ef115.tar.gz bcm5719-llvm-adb203feda9036d39ffecc21f5a9c463a20ef115.zip | |
[Stats] Add ALWAYS_ENABLED_STATISTIC enabled regardless of LLVM_ENABLE_STATS.
The intended usage is to measure relatively expensive operations. So the
cost of the statistic is negligible compared to the cost of a measured
operation and can be enabled all the time without impairing the
compilation time.
rdar://problem/55715134
Reviewers: dsanders, bogner, rtereshin
Reviewed By: dsanders
Subscribers: hiraditya, jkorous, dexonsmith, ributzka, cfe-commits, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D68252
llvm-svn: 374490
Diffstat (limited to 'llvm/unittests')
| -rw-r--r-- | llvm/unittests/ADT/StatisticTest.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/StatisticTest.cpp b/llvm/unittests/ADT/StatisticTest.cpp index 1b5530fb729..eb7a947224d 100644 --- a/llvm/unittests/ADT/StatisticTest.cpp +++ b/llvm/unittests/ADT/StatisticTest.cpp @@ -17,6 +17,7 @@ namespace { #define DEBUG_TYPE "unittest" STATISTIC(Counter, "Counts things"); STATISTIC(Counter2, "Counts other things"); +ALWAYS_ENABLED_STATISTIC(AlwaysCounter, "Counts things always"); #if LLVM_ENABLE_STATS static void @@ -43,6 +44,12 @@ TEST(StatisticTest, Count) { #else EXPECT_EQ(Counter, 0u); #endif + + AlwaysCounter = 0; + EXPECT_EQ(AlwaysCounter, 0u); + AlwaysCounter++; + ++AlwaysCounter; + EXPECT_EQ(AlwaysCounter, 2u); } TEST(StatisticTest, Assign) { @@ -54,6 +61,9 @@ TEST(StatisticTest, Assign) { #else EXPECT_EQ(Counter, 0u); #endif + + AlwaysCounter = 2; + EXPECT_EQ(AlwaysCounter, 2u); } TEST(StatisticTest, API) { |

