зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1438953
Increase the epsilon on timer reduction tests r=froydnj
In Javascript, we re-clamp timers to ensure they stay the same. Because of double imprecision sometimes they don't stay the same, and are clamped downwards. If that happens we detect it, and if we were originally off by an epsilon from a clamped value, we accept the value in the name of double imprecision. However, the epsilons were originally chosen somewhat arbitrarily. They worked for small numbers, where imprecision from doubles were very small. But large doubles have much less precise fractional parts. So the epsilons were too large for large numbers where the imprecision was larger. MozReview-Commit-ID: HnYYo4cuv96 --HG-- extra : rebase_source : 3a1d70e801fe7b8e1a8b2c191854db3db11751a9
This commit is contained in:
Родитель
3a72c74e9c
Коммит
aed0c1a052
|
@ -37,10 +37,15 @@ let isRounded = (x, expectedPrecision) => {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// When we're diving by non-whole numbers, we may not get perfect
|
// When we're diving by non-whole numbers, we may not get perfect
|
||||||
// multiplication/division because of floating points
|
// multiplication/division because of floating points.
|
||||||
if (Math.abs(rounded - x + expectedPrecision) < .0000001) {
|
// When dealing with ms since epoch, a double's precision is on the order
|
||||||
|
// of 1/5 of a microsecond, so we use a value a little higher than that as
|
||||||
|
// our epsilon.
|
||||||
|
// To be clear, this error is introduced in our re-calculation of 'rounded'
|
||||||
|
// above in JavaScript.
|
||||||
|
if (Math.abs(rounded - x + expectedPrecision) < .0005) {
|
||||||
return true;
|
return true;
|
||||||
} else if (Math.abs(rounded - x) < .0000001) {
|
} else if (Math.abs(rounded - x) < .0005) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,15 @@ let isRounded = (x, expectedPrecision) => {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// When we're diving by non-whole numbers, we may not get perfect
|
// When we're diving by non-whole numbers, we may not get perfect
|
||||||
// multiplication/division because of floating points
|
// multiplication/division because of floating points.
|
||||||
if (Math.abs(rounded - x + expectedPrecision) < .0000001) {
|
// When dealing with ms since epoch, a double's precision is on the order
|
||||||
|
// of 1/5 of a microsecond, so we use a value a little higher than that as
|
||||||
|
// our epsilon.
|
||||||
|
// To be clear, this error is introduced in our re-calculation of 'rounded'
|
||||||
|
// above in JavaScript.
|
||||||
|
if (Math.abs(rounded - x + expectedPrecision) < .0005) {
|
||||||
return true;
|
return true;
|
||||||
} else if (Math.abs(rounded - x) < .0000001) {
|
} else if (Math.abs(rounded - x) < .0005) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,10 +36,15 @@
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// When we're diving by non-whole numbers, we may not get perfect
|
// When we're diving by non-whole numbers, we may not get perfect
|
||||||
// multiplication/division because of floating points
|
// multiplication/division because of floating points.
|
||||||
if (Math.abs(rounded - x + expectedPrecision) < .0000001) {
|
// When dealing with ms since epoch, a double's precision is on the order
|
||||||
|
// of 1/5 of a microsecond, so we use a value a little higher than that as
|
||||||
|
// our epsilon.
|
||||||
|
// To be clear, this error is introduced in our re-calculation of 'rounded'
|
||||||
|
// above in JavaScript.
|
||||||
|
if (Math.abs(rounded - x + expectedPrecision) < .0005) {
|
||||||
return true;
|
return true;
|
||||||
} else if (Math.abs(rounded - x) < .0000001) {
|
} else if (Math.abs(rounded - x) < .0005) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,13 +50,18 @@ https://trac.torproject.org/projects/tor/ticket/1517
|
||||||
if (rounded === x || x === 0)
|
if (rounded === x || x === 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// When we're diving by non-whole numbers, we may not get perfect
|
// When we're diving by non-whole numbers, we may not get perfect
|
||||||
// multiplication/division because of floating points
|
// multiplication/division because of floating points.
|
||||||
if (Math.abs(rounded - x + expectedPrecision) < .0000001) {
|
// When dealing with ms since epoch, a double's precision is on the order
|
||||||
return true;
|
// of 1/5 of a microsecond, so we use a value a little higher than that as
|
||||||
} else if (Math.abs(rounded - x) < .0000001) {
|
// our epsilon.
|
||||||
return true;
|
// To be clear, this error is introduced in our re-calculation of 'rounded'
|
||||||
}
|
// above in JavaScript.
|
||||||
|
if (Math.abs(rounded - x + expectedPrecision) < .0005) {
|
||||||
|
return true;
|
||||||
|
} else if (Math.abs(rounded - x) < .0005) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Then we handle the case where you're sub-millisecond and the timer is not
|
// Then we handle the case where you're sub-millisecond and the timer is not
|
||||||
// We check that the timer is not sub-millisecond by assuming it is not if it
|
// We check that the timer is not sub-millisecond by assuming it is not if it
|
||||||
|
|
Загрузка…
Ссылка в новой задаче