File: resource_coalition_mac_unittest.mm

package info (click to toggle)
chromium 120.0.6099.224-1~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 6,112,112 kB
  • sloc: cpp: 32,907,025; ansic: 8,148,123; javascript: 3,679,536; python: 2,031,248; asm: 959,718; java: 804,675; xml: 617,256; sh: 111,417; objc: 100,835; perl: 88,443; cs: 53,032; makefile: 29,579; fortran: 24,137; php: 21,162; tcl: 21,147; sql: 20,809; ruby: 17,735; pascal: 12,864; yacc: 8,045; lisp: 3,388; lex: 1,323; ada: 727; awk: 329; jsp: 267; csh: 117; exp: 43; sed: 37
file content (425 lines) | stat: -rw-r--r-- 18,182 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/power_metrics/resource_coalition_mac.h"

#include "base/rand_util.h"
#include "components/power_metrics/energy_impact_mac.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/abseil-cpp/absl/types/optional.h"

namespace power_metrics {

namespace {

constexpr mach_timebase_info_data_t kIntelTimebase = {1, 1};
constexpr mach_timebase_info_data_t kM1Timebase = {125, 3};

constexpr EnergyImpactCoefficients kEnergyImpactCoefficients{
    .kcpu_wakeups = base::Microseconds(200).InSecondsF(),
    .kqos_default = 1.0,
    .kqos_background = 0.8,
    .kqos_utility = 1.0,
    .kqos_legacy = 1.0,
    .kqos_user_initiated = 1.0,
    .kqos_user_interactive = 1.0,
    .kgpu_time = 2.5,
};

coalition_resource_usage GetTestCoalitionResourceUsage(uint32_t increment) {
  coalition_resource_usage ret{
      .tasks_started = 1 + increment,
      .tasks_exited = 2 + increment,
      .time_nonempty = 3 + increment,
      .cpu_time = 4 + increment,
      .interrupt_wakeups = 5 + increment,
      .platform_idle_wakeups = 6 + increment,
      .bytesread = 7 + increment,
      .byteswritten = 8 + increment,
      .gpu_time = 9 + increment,
      .cpu_time_billed_to_me = 10 + increment,
      .cpu_time_billed_to_others = 11 + increment,
      .energy = 12 + increment,
      .logical_immediate_writes = 13 + increment,
      .logical_deferred_writes = 14 + increment,
      .logical_invalidated_writes = 15 + increment,
      .logical_metadata_writes = 16 + increment,
      .logical_immediate_writes_to_external = 17 + increment,
      .logical_deferred_writes_to_external = 18 + increment,
      .logical_invalidated_writes_to_external = 19 + increment,
      .logical_metadata_writes_to_external = 20 + increment,
      .energy_billed_to_me = 21 + increment,
      .energy_billed_to_others = 22 + increment,
      .cpu_ptime = 23 + increment,
      .cpu_time_eqos_len = COALITION_NUM_THREAD_QOS_TYPES,
      .cpu_instructions = 31 + increment,
      .cpu_cycles = 32 + increment,
      .fs_metadata_writes = 33 + increment,
      .pm_writes = 34 + increment,
  };

  ret.cpu_time_eqos[THREAD_QOS_DEFAULT] = 24 + increment;
  ret.cpu_time_eqos[THREAD_QOS_MAINTENANCE] = 25 + increment;
  ret.cpu_time_eqos[THREAD_QOS_BACKGROUND] = 26 + increment;
  ret.cpu_time_eqos[THREAD_QOS_UTILITY] = 27 + increment;
  ret.cpu_time_eqos[THREAD_QOS_LEGACY] = 28 + increment;
  ret.cpu_time_eqos[THREAD_QOS_USER_INITIATED] = 29 + increment;
  ret.cpu_time_eqos[THREAD_QOS_USER_INTERACTIVE] = 30 + increment;

  return ret;
}

void BurnCPU() {
  base::TimeTicks begin = base::TimeTicks::Now();
  constexpr base::TimeDelta busy_time = base::Seconds(1);
  [[maybe_unused]] volatile double number = 1;
  while (base::TimeTicks::Now() < (begin + busy_time)) {
    for (int i = 0; i < 10000; ++i)
      number = number * base::RandDouble();
  }
}

}  // namespace

TEST(ResourceCoalitionMacTest, Busy) {
  absl::optional<uint64_t> coalition_id =
      GetProcessCoalitionId(base::GetCurrentProcId());
  ASSERT_TRUE(coalition_id.has_value());

  std::unique_ptr<coalition_resource_usage> begin =
      GetCoalitionResourceUsage(coalition_id.value());
  BurnCPU();
  std::unique_ptr<coalition_resource_usage> end =
      GetCoalitionResourceUsage(coalition_id.value());

  ASSERT_TRUE(begin);
  ASSERT_TRUE(end);

  EXPECT_GT(end->cpu_instructions, begin->cpu_instructions);
  EXPECT_GT(end->cpu_cycles, begin->cpu_cycles);
  EXPECT_GT(end->cpu_time, begin->cpu_time);
}

TEST(ResourceCoalitionMacTest, Difference) {
  coalition_resource_usage left =
      GetTestCoalitionResourceUsage(/* increment= */ 1);
  coalition_resource_usage right =
      GetTestCoalitionResourceUsage(/* increment= */ 0);
  coalition_resource_usage diff =
      GetCoalitionResourceUsageDifference(left, right);

  EXPECT_EQ(diff.tasks_started, 1U);
  EXPECT_EQ(diff.tasks_exited, 1U);
  EXPECT_EQ(diff.time_nonempty, 1U);
  EXPECT_EQ(diff.cpu_time, 1U);
  EXPECT_EQ(diff.interrupt_wakeups, 1U);
  EXPECT_EQ(diff.platform_idle_wakeups, 1U);
  EXPECT_EQ(diff.bytesread, 1U);
  EXPECT_EQ(diff.byteswritten, 1U);
  EXPECT_EQ(diff.gpu_time, 1U);
  EXPECT_EQ(diff.cpu_time_billed_to_me, 1U);
  EXPECT_EQ(diff.cpu_time_billed_to_others, 1U);
  EXPECT_EQ(diff.energy, 1U);
  EXPECT_EQ(diff.logical_immediate_writes, 1U);
  EXPECT_EQ(diff.logical_deferred_writes, 1U);
  EXPECT_EQ(diff.logical_invalidated_writes, 1U);
  EXPECT_EQ(diff.logical_metadata_writes, 1U);
  EXPECT_EQ(diff.logical_immediate_writes_to_external, 1U);
  EXPECT_EQ(diff.logical_deferred_writes_to_external, 1U);
  EXPECT_EQ(diff.logical_invalidated_writes_to_external, 1U);
  EXPECT_EQ(diff.logical_metadata_writes_to_external, 1U);
  EXPECT_EQ(diff.energy_billed_to_me, 1U);
  EXPECT_EQ(diff.energy_billed_to_others, 1U);
  EXPECT_EQ(diff.cpu_ptime, 1U);
  EXPECT_EQ(diff.cpu_time_eqos_len,
            static_cast<uint64_t>(COALITION_NUM_THREAD_QOS_TYPES));

  for (int i = 0; i < COALITION_NUM_THREAD_QOS_TYPES; ++i)
    EXPECT_EQ(diff.cpu_time_eqos[i], 1U);

  EXPECT_EQ(diff.cpu_instructions, 1U);
  EXPECT_EQ(diff.cpu_cycles, 1U);
  EXPECT_EQ(diff.fs_metadata_writes, 1U);
  EXPECT_EQ(diff.pm_writes, 1U);
}

namespace {

constexpr base::TimeDelta kIntervalDuration = base::Seconds(2.5);

constexpr double kExpectedCPUUsagePerSecondPercent = 0.7;
constexpr double kExpectedGPUUsagePerSecondPercent = 0.3;
// Note: The following counters must have an integral value once multiplied by
// the interval length in seconds (2.5).
constexpr double kExpectedInterruptWakeUpPerSecond = 0.4;
constexpr double kExpectedPlatformIdleWakeUpPerSecond = 10;
constexpr double kExpectedBytesReadPerSecond = 0.8;
constexpr double kExpectedBytesWrittenPerSecond = 1.6;
constexpr double kExpectedPowerNW = 10000.0;
// This number will be multiplied by the int value associated with a QoS level
// to compute the expected time spent in this QoS level. E.g.
// |QoSLevels::kUtility == 3| so the time spent in the utility QoS state will
// be set to 3 * 0.1 = 30%.
constexpr double kExpectedQoSTimeBucketIdMultiplier = 0.1;

// Scales a time given in ns to mach_time in |timebase|.
uint64_t NsScaleToTimebase(const mach_timebase_info_data_t& timebase,
                           int64_t time_ns) {
  return time_ns * timebase.denom / timebase.numer;
}

// Returns test data with all time quantities scaled to the given time base.
std::unique_ptr<coalition_resource_usage> GetCoalitionResourceUsageRateTestData(
    const mach_timebase_info_data_t& timebase) {
  std::unique_ptr<coalition_resource_usage> test_data =
      std::make_unique<coalition_resource_usage>();

  // Scales a time given in ns to mach_time in |timebase|.
  auto scale_to_timebase = [&timebase](double time_ns) -> int64_t {
    return NsScaleToTimebase(timebase, time_ns);
  };

  test_data->cpu_time = scale_to_timebase(kExpectedCPUUsagePerSecondPercent *
                                          kIntervalDuration.InNanoseconds());
  test_data->interrupt_wakeups =
      kExpectedInterruptWakeUpPerSecond * kIntervalDuration.InSecondsF();
  test_data->platform_idle_wakeups =
      kExpectedPlatformIdleWakeUpPerSecond * kIntervalDuration.InSecondsF();
  test_data->bytesread =
      kExpectedBytesReadPerSecond * kIntervalDuration.InSecondsF();
  test_data->byteswritten =
      kExpectedBytesWrittenPerSecond * kIntervalDuration.InSecondsF();
  test_data->gpu_time = scale_to_timebase(kExpectedGPUUsagePerSecondPercent *
                                          kIntervalDuration.InNanoseconds());
  test_data->energy = kExpectedPowerNW * kIntervalDuration.InSecondsF();
  for (int i = 0; i < COALITION_NUM_THREAD_QOS_TYPES; ++i) {
    test_data->cpu_time_eqos[i] =
        scale_to_timebase(i * kExpectedQoSTimeBucketIdMultiplier *
                          kIntervalDuration.InNanoseconds());
  }
  test_data->cpu_time_eqos_len = COALITION_NUM_THREAD_QOS_TYPES;

  return test_data;
}

}  // namespace

TEST(ResourceCoalitionMacTest, GetDataRate_NoEnergyImpact_Intel) {
  // Keep the initial data zero initialized.
  std::unique_ptr<coalition_resource_usage> t0_data =
      std::make_unique<coalition_resource_usage>();
  std::unique_ptr<coalition_resource_usage> t1_data =
      GetCoalitionResourceUsageRateTestData(kIntelTimebase);

  auto rate = GetCoalitionResourceUsageRate(
      *t0_data, *t1_data, kIntervalDuration, kIntelTimebase, absl::nullopt);
  ASSERT_TRUE(rate);
  EXPECT_EQ(kExpectedCPUUsagePerSecondPercent, rate->cpu_time_per_second);
  EXPECT_EQ(kExpectedInterruptWakeUpPerSecond,
            rate->interrupt_wakeups_per_second);
  EXPECT_EQ(kExpectedPlatformIdleWakeUpPerSecond,
            rate->platform_idle_wakeups_per_second);
  EXPECT_EQ(kExpectedBytesReadPerSecond, rate->bytesread_per_second);
  EXPECT_EQ(kExpectedBytesWrittenPerSecond, rate->byteswritten_per_second);
  EXPECT_EQ(kExpectedGPUUsagePerSecondPercent, rate->gpu_time_per_second);
  EXPECT_FALSE(rate->energy_impact_per_second.has_value());
  EXPECT_EQ(kExpectedPowerNW, rate->power_nw);

  for (int i = 0; i < COALITION_NUM_THREAD_QOS_TYPES; ++i) {
    EXPECT_DOUBLE_EQ(i * kExpectedQoSTimeBucketIdMultiplier,
                     rate->qos_time_per_second[i]);
  }
}

TEST(ResourceCoalitionMacTest, GetDataRate_NoEnergyImpact_M1) {
  // Keep the initial data zero initialized.
  std::unique_ptr<coalition_resource_usage> t0_data =
      std::make_unique<coalition_resource_usage>();
  std::unique_ptr<coalition_resource_usage> t1_data =
      GetCoalitionResourceUsageRateTestData(kM1Timebase);

  auto rate = GetCoalitionResourceUsageRate(
      *t0_data, *t1_data, kIntervalDuration, kM1Timebase, absl::nullopt);
  ASSERT_TRUE(rate);
  EXPECT_DOUBLE_EQ(kExpectedCPUUsagePerSecondPercent,
                   rate->cpu_time_per_second);
  EXPECT_DOUBLE_EQ(kExpectedInterruptWakeUpPerSecond,
                   rate->interrupt_wakeups_per_second);
  EXPECT_DOUBLE_EQ(kExpectedPlatformIdleWakeUpPerSecond,
                   rate->platform_idle_wakeups_per_second);
  EXPECT_DOUBLE_EQ(kExpectedBytesReadPerSecond, rate->bytesread_per_second);
  EXPECT_DOUBLE_EQ(kExpectedBytesWrittenPerSecond,
                   rate->byteswritten_per_second);
  EXPECT_DOUBLE_EQ(kExpectedGPUUsagePerSecondPercent,
                   rate->gpu_time_per_second);
  EXPECT_FALSE(rate->energy_impact_per_second.has_value());
  EXPECT_DOUBLE_EQ(kExpectedPowerNW, rate->power_nw);

  for (int i = 0; i < COALITION_NUM_THREAD_QOS_TYPES; ++i) {
    EXPECT_DOUBLE_EQ(i * kExpectedQoSTimeBucketIdMultiplier,
                     rate->qos_time_per_second[i]);
  }
}

TEST(ResourceCoalitionMacTest, GetDataRate_WithEnergyImpact_Intel) {
  std::unique_ptr<coalition_resource_usage> t0_data =
      std::make_unique<coalition_resource_usage>();
  std::unique_ptr<coalition_resource_usage> t1_data =
      GetCoalitionResourceUsageRateTestData(kIntelTimebase);

  auto rate =
      GetCoalitionResourceUsageRate(*t0_data, *t1_data, kIntervalDuration,
                                    kIntelTimebase, kEnergyImpactCoefficients);
  ASSERT_TRUE(rate);
  EXPECT_EQ(kExpectedCPUUsagePerSecondPercent, rate->cpu_time_per_second);
  EXPECT_EQ(kExpectedInterruptWakeUpPerSecond,
            rate->interrupt_wakeups_per_second);
  EXPECT_EQ(kExpectedPlatformIdleWakeUpPerSecond,
            rate->platform_idle_wakeups_per_second);
  EXPECT_EQ(kExpectedBytesReadPerSecond, rate->bytesread_per_second);
  EXPECT_EQ(kExpectedBytesWrittenPerSecond, rate->byteswritten_per_second);
  EXPECT_EQ(kExpectedGPUUsagePerSecondPercent, rate->gpu_time_per_second);
  ASSERT_TRUE(rate->energy_impact_per_second.has_value());
  EXPECT_EQ(271.2, rate->energy_impact_per_second.value());
  EXPECT_FLOAT_EQ(kExpectedPowerNW, rate->power_nw);

  for (int i = 0; i < COALITION_NUM_THREAD_QOS_TYPES; ++i) {
    EXPECT_DOUBLE_EQ(i * kExpectedQoSTimeBucketIdMultiplier,
                     rate->qos_time_per_second[i]);
  }
}

TEST(ResourceCoalitionMacTest, GetDataRate_WithEnergyImpact_M1) {
  std::unique_ptr<coalition_resource_usage> t0_data =
      std::make_unique<coalition_resource_usage>();
  std::unique_ptr<coalition_resource_usage> t1_data =
      GetCoalitionResourceUsageRateTestData(kM1Timebase);

  auto rate =
      GetCoalitionResourceUsageRate(*t0_data, *t1_data, kIntervalDuration,
                                    kM1Timebase, kEnergyImpactCoefficients);
  ASSERT_TRUE(rate);
  EXPECT_EQ(kExpectedCPUUsagePerSecondPercent, rate->cpu_time_per_second);
  EXPECT_EQ(kExpectedInterruptWakeUpPerSecond,
            rate->interrupt_wakeups_per_second);
  EXPECT_EQ(kExpectedPlatformIdleWakeUpPerSecond,
            rate->platform_idle_wakeups_per_second);
  EXPECT_EQ(kExpectedBytesReadPerSecond, rate->bytesread_per_second);
  EXPECT_EQ(kExpectedBytesWrittenPerSecond, rate->byteswritten_per_second);
  EXPECT_EQ(kExpectedGPUUsagePerSecondPercent, rate->gpu_time_per_second);
  ASSERT_TRUE(rate->energy_impact_per_second.has_value());
  EXPECT_EQ(271.2, rate->energy_impact_per_second.value());
  EXPECT_FLOAT_EQ(kExpectedPowerNW, rate->power_nw);

  for (int i = 0; i < COALITION_NUM_THREAD_QOS_TYPES; ++i) {
    EXPECT_DOUBLE_EQ(i * kExpectedQoSTimeBucketIdMultiplier,
                     rate->qos_time_per_second[i]);
  }
}

namespace {

bool DataOverflowInvalidatesDiffImpl(
    std::unique_ptr<coalition_resource_usage> t0,
    std::unique_ptr<coalition_resource_usage> t1,
    uint64_t* field_to_overflow) {
  // Initialize all fields to a non zero value.
  ::memset(t0.get(), 1000, sizeof(coalition_resource_usage));
  ::memset(t1.get(), 1000, sizeof(coalition_resource_usage));
  *field_to_overflow = 0;
  t1->cpu_time_eqos_len = COALITION_NUM_THREAD_QOS_TYPES;
  return !GetCoalitionResourceUsageRate(*t0, *t1, kIntervalDuration,
                                        kIntelTimebase, absl::nullopt)
              .has_value();
}

bool DataOverflowInvalidatesDiff(
    uint64_t coalition_resource_usage::*member_ptr) {
  std::unique_ptr<coalition_resource_usage> t0_data =
      std::make_unique<coalition_resource_usage>();
  std::unique_ptr<coalition_resource_usage> t1_data =
      std::make_unique<coalition_resource_usage>();
  auto* ptr = &(t1_data.get()->*member_ptr);
  return DataOverflowInvalidatesDiffImpl(std::move(t0_data), std::move(t1_data),
                                         ptr);
}

bool DataOverflowInvalidatesDiff(
    uint64_t (
        coalition_resource_usage::*member_ptr)[COALITION_NUM_THREAD_QOS_TYPES],
    int index_to_check) {
  std::unique_ptr<coalition_resource_usage> t0_data =
      std::make_unique<coalition_resource_usage>();
  std::unique_ptr<coalition_resource_usage> t1_data =
      std::make_unique<coalition_resource_usage>();
  auto* ptr = &(t1_data.get()->*member_ptr)[index_to_check];
  return DataOverflowInvalidatesDiffImpl(std::move(t0_data), std::move(t1_data),
                                         ptr);
}

}  // namespace

// If one of these tests fails then it means that overflows on a newly tracked
// coalition field aren't tracked properly in GetCoalitionResourceUsageRate().
TEST(ResourceCoalitionTests, Overflows) {
  EXPECT_FALSE(DataOverflowInvalidatesDiff(
      &coalition_resource_usage::energy_billed_to_me));
  EXPECT_FALSE(
      DataOverflowInvalidatesDiff(&coalition_resource_usage::tasks_started));
  EXPECT_FALSE(
      DataOverflowInvalidatesDiff(&coalition_resource_usage::tasks_exited));
  EXPECT_FALSE(
      DataOverflowInvalidatesDiff(&coalition_resource_usage::time_nonempty));
  EXPECT_TRUE(DataOverflowInvalidatesDiff(&coalition_resource_usage::cpu_time));
  EXPECT_TRUE(DataOverflowInvalidatesDiff(
      &coalition_resource_usage::interrupt_wakeups));
  EXPECT_TRUE(DataOverflowInvalidatesDiff(
      &coalition_resource_usage::platform_idle_wakeups));
  EXPECT_TRUE(
      DataOverflowInvalidatesDiff(&coalition_resource_usage::bytesread));
  EXPECT_TRUE(
      DataOverflowInvalidatesDiff(&coalition_resource_usage::byteswritten));
  EXPECT_TRUE(DataOverflowInvalidatesDiff(&coalition_resource_usage::gpu_time));
  EXPECT_FALSE(DataOverflowInvalidatesDiff(
      &coalition_resource_usage::cpu_time_billed_to_me));
  EXPECT_FALSE(DataOverflowInvalidatesDiff(
      &coalition_resource_usage::cpu_time_billed_to_others));
  EXPECT_TRUE(DataOverflowInvalidatesDiff(&coalition_resource_usage::energy));
  EXPECT_FALSE(DataOverflowInvalidatesDiff(
      &coalition_resource_usage::logical_immediate_writes));
  EXPECT_FALSE(DataOverflowInvalidatesDiff(
      &coalition_resource_usage::logical_deferred_writes));
  EXPECT_FALSE(DataOverflowInvalidatesDiff(
      &coalition_resource_usage::logical_invalidated_writes));
  EXPECT_FALSE(DataOverflowInvalidatesDiff(
      &coalition_resource_usage::logical_metadata_writes));
  EXPECT_FALSE(DataOverflowInvalidatesDiff(
      &coalition_resource_usage::logical_immediate_writes_to_external));
  EXPECT_FALSE(DataOverflowInvalidatesDiff(
      &coalition_resource_usage::logical_deferred_writes_to_external));
  EXPECT_FALSE(DataOverflowInvalidatesDiff(
      &coalition_resource_usage::logical_invalidated_writes_to_external));
  EXPECT_FALSE(DataOverflowInvalidatesDiff(
      &coalition_resource_usage::logical_metadata_writes_to_external));
  EXPECT_FALSE(DataOverflowInvalidatesDiff(
      &coalition_resource_usage::energy_billed_to_me));
  EXPECT_FALSE(DataOverflowInvalidatesDiff(
      &coalition_resource_usage::energy_billed_to_others));
  EXPECT_FALSE(
      DataOverflowInvalidatesDiff(&coalition_resource_usage::cpu_ptime));
  for (int i = 0; i < COALITION_NUM_THREAD_QOS_TYPES; ++i) {
    EXPECT_TRUE(DataOverflowInvalidatesDiff(
        &coalition_resource_usage::cpu_time_eqos, i));
  }
  EXPECT_FALSE(
      DataOverflowInvalidatesDiff(&coalition_resource_usage::cpu_instructions));
  EXPECT_FALSE(
      DataOverflowInvalidatesDiff(&coalition_resource_usage::cpu_cycles));
  EXPECT_FALSE(DataOverflowInvalidatesDiff(
      &coalition_resource_usage::fs_metadata_writes));
  EXPECT_FALSE(
      DataOverflowInvalidatesDiff(&coalition_resource_usage::pm_writes));
}

}  // namespace power_metrics