OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 TimingSample sample(&foo); | 204 TimingSample sample(&foo); |
205 | 205 |
206 ::Sleep(30); | 206 ::Sleep(30); |
207 } | 207 } |
208 | 208 |
209 TimingMetric::TimingData data = foo.Reset(); | 209 TimingMetric::TimingData data = foo.Reset(); |
210 | 210 |
211 // Should be precisely one sample in there | 211 // Should be precisely one sample in there |
212 EXPECT_EQ(1, data.count); | 212 EXPECT_EQ(1, data.count); |
213 | 213 |
214 // Disable flaky tests on build server, unfortunately this reduces coverage | |
215 // too, but it seems preferrable to breaking the build on a regular basis. | |
216 #ifndef BUILD_SERVER_BUILD | |
217 // Let's hope the scheduler doesn't leave us hanging more than 10 ms. | |
218 EXPECT_GT(40, data.sum); | |
219 // The sleep above seems to often terminate early on the build server, | |
220 // I've observed captured times down to 18 ms, which is strange. | |
221 // TODO: figure out whether the timer is broken or whether | |
222 // sleep is breaking its promise, or whether e.g. we're getting different | |
223 // walltimes on different CPUs due to BIOS bugs on the build server | |
224 EXPECT_LT(15, data.sum); | |
225 #endif | |
226 | |
227 // again, this time with a non-unity count | 214 // again, this time with a non-unity count |
228 { | 215 { |
229 TimingSample sample(&foo, 2); | 216 TimingSample sample(&foo, 2); |
230 | 217 |
231 EXPECT_EQ(2, sample.count()); | 218 EXPECT_EQ(2, sample.count()); |
232 ::Sleep(30); | 219 ::Sleep(30); |
233 } | 220 } |
234 | 221 |
235 data = foo.Reset(); | 222 data = foo.Reset(); |
236 | 223 |
237 // Should be precisely two samples in there | 224 // Should be precisely two samples in there |
238 EXPECT_EQ(2, data.count); | 225 EXPECT_EQ(2, data.count); |
239 | 226 |
240 // Disable flaky tests on build server, unfortunately this reduces coverage | |
241 // too, but it seems preferrable to breaking the build on a regular basis. | |
242 #ifndef BUILD_SERVER_BUILD | |
243 // Let's hope the scheduler doesn't leave us hanging more than 10 ms. | |
244 EXPECT_GT(40, data.sum); | |
245 EXPECT_LT(15, data.sum); | |
246 #endif | |
247 | |
248 // now with zero count | 227 // now with zero count |
249 { | 228 { |
250 TimingSample sample(&foo, 0); | 229 TimingSample sample(&foo, 0); |
251 } | 230 } |
252 | 231 |
253 data = foo.Reset(); | 232 data = foo.Reset(); |
254 | 233 |
255 // Should be no samples in there | 234 // Should be no samples in there |
256 EXPECT_EQ(0, data.count); | 235 EXPECT_EQ(0, data.count); |
257 } | 236 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 EXPECT_STREQ("bool_true", bool_true.name()); | 377 EXPECT_STREQ("bool_true", bool_true.name()); |
399 EXPECT_TRUE(NULL == bool_true.next()); | 378 EXPECT_TRUE(NULL == bool_true.next()); |
400 | 379 |
401 const BoolMetric bool_false("bool_false", BoolMetric::kBoolFalse); | 380 const BoolMetric bool_false("bool_false", BoolMetric::kBoolFalse); |
402 | 381 |
403 EXPECT_EQ(BoolMetric::kBoolFalse, bool_false.value()); | 382 EXPECT_EQ(BoolMetric::kBoolFalse, bool_false.value()); |
404 EXPECT_EQ(kBoolType, bool_false.type()); | 383 EXPECT_EQ(kBoolType, bool_false.type()); |
405 EXPECT_STREQ("bool_false", bool_false.name()); | 384 EXPECT_STREQ("bool_false", bool_false.name()); |
406 EXPECT_TRUE(NULL == bool_false.next()); | 385 EXPECT_TRUE(NULL == bool_false.next()); |
407 } | 386 } |
OLD | NEW |