From patchwork Thu Jun 25 23:26:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lespiau, Damien" X-Patchwork-Id: 6677881 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 87BF79F380 for ; Thu, 25 Jun 2015 23:27:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BF57C20748 for ; Thu, 25 Jun 2015 23:27:22 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 338E020711 for ; Thu, 25 Jun 2015 23:27:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 55D104A044; Thu, 25 Jun 2015 16:27:19 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 8BD534A034 for ; Thu, 25 Jun 2015 16:27:17 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 25 Jun 2015 16:27:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,680,1427785200"; d="scan'208";a="594940266" Received: from mpaszkie-mobl1.ger.corp.intel.com (HELO strange.ger.corp.intel.com) ([10.252.33.58]) by orsmga003.jf.intel.com with ESMTP; 25 Jun 2015 16:27:08 -0700 From: Damien Lespiau To: intel-gfx@lists.freedesktop.org Date: Fri, 26 Jun 2015 00:26:59 +0100 Message-Id: <1435274819-2777-5-git-send-email-damien.lespiau@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1435274819-2777-1-git-send-email-damien.lespiau@intel.com> References: <1435274819-2777-1-git-send-email-damien.lespiau@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 5/5] tests/stats: Make sure we properly invalidate the cached mean X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sure, that's an implementation details, but make sure we do recompute the mean when we add a new value. Signed-off-by: Damien Lespiau --- lib/tests/igt_stats.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/tests/igt_stats.c b/lib/tests/igt_stats.c index 172e4b3..f9081c7 100644 --- a/lib/tests/igt_stats.c +++ b/lib/tests/igt_stats.c @@ -45,6 +45,30 @@ static void test_mean(void) igt_stats_fini(&stats); } +static void test_invalidate_mean(void) +{ + igt_stats_t stats; + double mean1, mean2; + + igt_stats_init(&stats, 6); + + igt_stats_push(&stats, 2); + igt_stats_push(&stats, 4); + igt_stats_push(&stats, 6); + igt_stats_push(&stats, 8); + igt_stats_push(&stats, 10); + + mean1 = igt_stats_get_mean(&stats); + igt_assert(mean1 == (2 + 4 + 6 + 8 + 10) / 5.); + + igt_stats_push(&stats, 100); + + mean2 = igt_stats_get_mean(&stats); + igt_assert(mean1 != mean2); + + igt_stats_fini(&stats); +} + /* * Taken from the "Basic examples" section of: * https://en.wikipedia.org/wiki/Standard_deviation @@ -80,5 +104,6 @@ static void test_std_deviation(void) igt_simple_main { test_mean(); + test_invalidate_mean(); test_std_deviation(); }