Bug 1775285 - Counters should output a 0 sample at the beginning of a time without change, r=gerald.

Differential Revision: https://phabricator.services.mozilla.com/D149890
This commit is contained in:
Florian Queze 2022-06-29 13:29:43 +00:00
Родитель d06eb5a8cc
Коммит 48b13164be
2 изменённых файлов: 7 добавлений и 3 удалений

Просмотреть файл

@ -1812,7 +1812,10 @@ void ProfileBuffer::StreamCountersToJSON(
// or next sample; Always write the first and last samples.
if (i == 0 || i == size - 1 ||
samples[i].mNumber != previousNumber ||
samples[i].mCount != previousCount) {
samples[i].mCount != previousCount ||
// Ensure we ouput the first 0 before skipping samples.
(i >= 2 && (samples[i - 2].mNumber != previousNumber ||
samples[i - 2].mCount != previousCount))) {
if (i != 0 && samples[i].mTime >= samples[i - 1].mTime) {
MOZ_LOG(sFuzzyfoxLog, mozilla::LogLevel::Error,
("Fuzzyfox Profiler Assertion: %f >= %f",

Просмотреть файл

@ -3493,8 +3493,9 @@ TEST(GeckoProfiler, Counters)
};
int64_t testCounters[] = {10, 7, -17};
NumberAndCount expectedTestCounters[] = {{1u, 10}, {0u, 0}, {1u, 7},
{0u, 0}, {1u, -17}, {0u, 0}};
NumberAndCount expectedTestCounters[] = {{1u, 10}, {0u, 0}, {1u, 7},
{0u, 0}, {0u, 0}, {1u, -17},
{0u, 0}, {0u, 0}};
constexpr size_t expectedTestCountersCount =
MOZ_ARRAY_LENGTH(expectedTestCounters);