From patchwork Thu Jun 25 23:26:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lespiau, Damien" X-Patchwork-Id: 6677871 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A8DD8C05AC 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 A0E3A20747 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 A999720704 for ; Thu, 25 Jun 2015 23:27:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BABFE4A03C; Thu, 25 Jun 2015 16:27:18 -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 683C34A03C 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="594940251" 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:07 -0700 From: Damien Lespiau To: intel-gfx@lists.freedesktop.org Date: Fri, 26 Jun 2015 00:26:58 +0100 Message-Id: <1435274819-2777-4-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 4/5] stats: Add a way to retrieve the standard deviation 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 Signed-off-by: Damien Lespiau --- lib/igt_stats.c | 9 +++++++++ lib/igt_stats.h | 1 + lib/tests/Makefile.am | 2 +- lib/tests/igt_stats.c | 33 +++++++++++++++++++++++++++++++++ tools/Makefile.am | 2 +- tools/quick_dump/Makefile.am | 1 + 6 files changed, 46 insertions(+), 2 deletions(-) diff --git a/lib/igt_stats.c b/lib/igt_stats.c index 20db806..65c0ac6 100644 --- a/lib/igt_stats.c +++ b/lib/igt_stats.c @@ -22,6 +22,8 @@ * */ +#include + #include "igt_core.h" #include "igt_stats.h" @@ -86,3 +88,10 @@ double igt_stats_get_variance(igt_stats_t *stats) return stats->variance; } + +double igt_stats_get_std_deviation(igt_stats_t *stats) +{ + igt_stats_knuth_mean_variance(stats); + + return sqrt(stats->variance); +} diff --git a/lib/igt_stats.h b/lib/igt_stats.h index acb86a6..371def3 100644 --- a/lib/igt_stats.h +++ b/lib/igt_stats.h @@ -37,3 +37,4 @@ void igt_stats_fini(igt_stats_t *stats); void igt_stats_push(igt_stats_t *stats, uint64_t value); double igt_stats_get_mean(igt_stats_t *stats); double igt_stats_get_variance(igt_stats_t *stats); +double igt_stats_get_std_deviation(igt_stats_t *stats); diff --git a/lib/tests/Makefile.am b/lib/tests/Makefile.am index e59065b..938d2ab 100644 --- a/lib/tests/Makefile.am +++ b/lib/tests/Makefile.am @@ -15,5 +15,5 @@ AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) \ LDADD = ../libintel_tools.la $(PCIACCESS_LIBS) $(DRM_LIBS) $(LIBUNWIND_LIBS) -LDADD += $(CAIRO_LIBS) $(LIBUDEV_LIBS) $(GLIB_LIBS) +LDADD += $(CAIRO_LIBS) $(LIBUDEV_LIBS) $(GLIB_LIBS) -lm AM_CFLAGS += $(CAIRO_CFLAGS) $(LIBUDEV_CFLAGS) $(GLIB_CFLAGS) diff --git a/lib/tests/igt_stats.c b/lib/tests/igt_stats.c index c20b453..172e4b3 100644 --- a/lib/tests/igt_stats.c +++ b/lib/tests/igt_stats.c @@ -45,7 +45,40 @@ static void test_mean(void) igt_stats_fini(&stats); } +/* + * Taken from the "Basic examples" section of: + * https://en.wikipedia.org/wiki/Standard_deviation + */ +static void test_std_deviation(void) +{ + igt_stats_t stats; + double mean, variance, std_deviation; + + igt_stats_init(&stats, 8); + + igt_stats_push(&stats, 2); + igt_stats_push(&stats, 4); + igt_stats_push(&stats, 4); + igt_stats_push(&stats, 4); + igt_stats_push(&stats, 5); + igt_stats_push(&stats, 5); + igt_stats_push(&stats, 7); + igt_stats_push(&stats, 9); + + mean = igt_stats_get_mean(&stats); + igt_assert(mean == (2 + 3 * 4 + 2 * 5 + 7 + 9) / 8.); + + variance = igt_stats_get_variance(&stats); + igt_assert(variance == 4); + + std_deviation = igt_stats_get_std_deviation(&stats); + igt_assert(std_deviation == 2); + + igt_stats_fini(&stats); +} + igt_simple_main { test_mean(); + test_std_deviation(); } diff --git a/tools/Makefile.am b/tools/Makefile.am index 04bfd12..8288248 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -8,5 +8,5 @@ endif AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/lib AM_CFLAGS = $(DRM_CFLAGS) $(PCIACCESS_CFLAGS) $(CWARNFLAGS) $(CAIRO_CFLAGS) $(LIBUNWIND_CFLAGS) -LDADD = $(top_builddir)/lib/libintel_tools.la $(DRM_LIBS) $(PCIACCESS_LIBS) $(CAIRO_LIBS) $(LIBUDEV_LIBS) $(LIBUNWIND_LIBS) +LDADD = $(top_builddir)/lib/libintel_tools.la $(DRM_LIBS) $(PCIACCESS_LIBS) $(CAIRO_LIBS) $(LIBUDEV_LIBS) $(LIBUNWIND_LIBS) -lm diff --git a/tools/quick_dump/Makefile.am b/tools/quick_dump/Makefile.am index 3d0bd23..0643a81 100644 --- a/tools/quick_dump/Makefile.am +++ b/tools/quick_dump/Makefile.am @@ -15,6 +15,7 @@ I915ChipsetPython_la_LIBADD = \ $(CAIRO_LIBS) \ $(LIBUNWIND_LIBS) \ -lrt \ + -lm \ $(NULL) chipset.py: chipset_wrap_python.c