All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dorota Czaplejewicz <dorota.czaplejewicz@collabora.co.uk>
To: Intel GFX discussion <intel-gfx@lists.freedesktop.org>
Subject: [PATCH i-g-t 1/2] igt/kms_setmode.c: Tweak timings check constants
Date: Wed, 30 Nov 2016 17:05:34 +0100	[thread overview]
Message-ID: <20161130170534.787fbd22@collabora.co.uk> (raw)

Add explanations of the checks and note the way the constants were derived.
Tweak the constants to reflect their purpose better.
---
 tests/kms_setmode.c | 36 +++++++++++++++++++++++++++++++++---
 1 file changed, 33 insertions(+), 3 deletions(-)

diff --git a/tests/kms_setmode.c b/tests/kms_setmode.c
index 4031d81..74eed88 100644
--- a/tests/kms_setmode.c
+++ b/tests/kms_setmode.c
@@ -474,18 +474,48 @@ static void check_timings(int crtc_idx, const drmModeModeInfo *kmode)
 
 	mean = igt_stats_get_mean(&stats);
 	stddev = igt_stats_get_std_deviation(&stats);
-	accuracy = 3.090 * stddev; /* 2-tailed 99% confidence */
+
+	/* 99.7% samples fall within `accuracy` on both sides of mean in normal
+	 * distribution if `accuracy = 3 * sigma`.
+	 * https://en.wikipedia.org/wiki/68%E2%80%9395%E2%80%9399.7_rule
+	 *
+	 * The value of 99.7% was chosen to suit requirements of test cases
+	 * which depend on timing, giving the lowest acceptable MTBF of 5.6s
+	 * for 60Hz sampling rate.
+	 */
+	accuracy = 3. * stddev;
 
 	igt_info("Expected frametime: %.0fus; measured %.1fus +- %.3fus accuracy %.2f%% [%.2f scanlines]\n",
 		 expected, mean, stddev,
 		 100 * accuracy / mean, accuracy / line_time(kmode));
 
-	/* 99% accuracy within one scanline */
+	/* 99.7% samples within one scanline on each side of mean */
 	igt_assert_f(accuracy < line_time(kmode),
 		     "vblank accuracy (%.3fus, %.1f%%) worse than a scanline (%.3fus)\n",
 		     accuracy, 100 * accuracy / mean, line_time(kmode));
 
-	igt_assert_f(fabs(mean - expected) < 2*stddev,
+	/* At least 90% of frame times fall within the one scanline on each
+	 * side of expected mean.
+	 *
+	 * Expected scanline duration:
+	 * 	(expected - accuracy, expected + accuracy).
+	 * Assuming maximum difference allowed:
+	 * 	expected = mean + n * sigma
+	 * the scanline duration becomes:
+	 * 	(mean - accuracy + n * sigma, mean + accuracy + n * sigma)
+	 * The expected scanline captures the following number of samples
+	 * from each side of expected:
+	 * 	(erf(abs(-(accuracy/sigma) + n) / sqrt(2))
+	 * 	+ erf((accuracy/sigma) + n) / sqrt(2))) / 2
+	 * 	= samples
+	 *
+	 * Solving for samples = 0.9:
+	 * 	n = 1.718
+	 *
+	 * See:
+	 * https://en.wikipedia.org/wiki/Standard_deviation#Rules_for_normally_distributed_data
+	 */
+	igt_assert_f(fabs(mean - expected) < 1.718 * stddev,
 		     "vblank interval differs from modeline! expected %.1fus, measured %1.fus +- %.3fus, difference %.1fus (%.1f sigma)\n",
 		     expected, mean, stddev,
 		     fabs(mean - expected), fabs(mean - expected) / stddev);
-- 
2.7.4
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

             reply	other threads:[~2016-11-30 16:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-30 16:05 Dorota Czaplejewicz [this message]
2016-11-30 16:06 ` [PATCH i-g-t 2/2] igt/kms_flip.c: Fix timings check Dorota Czaplejewicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161130170534.787fbd22@collabora.co.uk \
    --to=dorota.czaplejewicz@collabora.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.