From patchwork Wed Jul 27 12:38:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 9249771 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1AFE1607D8 for ; Wed, 27 Jul 2016 12:39:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C6501FF0B for ; Wed, 27 Jul 2016 12:39:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 000DE271FD; Wed, 27 Jul 2016 12:39:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD6A01FF0B for ; Wed, 27 Jul 2016 12:39:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2C2CC6E6B6; Wed, 27 Jul 2016 12:39:04 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 078E96E6B1 for ; Wed, 27 Jul 2016 12:38:35 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id q128so6281787wma.1 for ; Wed, 27 Jul 2016 05:38:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Yz+qXzU2EF1Gtz1aE84Mn1cifkzF1a+PBxL5mGTPyxQ=; b=VXw/1HMbBb175nnT1sO/lEKBQ6HODFxbYghGUbkrpoqWRG6NgvpDm7AQ+87nmUdaxu rp/g46JW1WbTn+z0vrlsrQc8TgZLPLCcprQlBIWvDM736wTCQhRhR0L84HLAsqdljB3t obOjOUaIFy/xKOMgUpvwL64c8UQVNL8MM2Rp8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Yz+qXzU2EF1Gtz1aE84Mn1cifkzF1a+PBxL5mGTPyxQ=; b=jiNiYpxrpA4A2/J+uyLLt8+UQ7BbwvY4ATY/rA8xYQU7QhyqxX34CnKBmHg38Yjw6D f6rvYyfktlm5fPQOHitY09BnEZpJeyOVw41qMXbbrARoKUucVUwCiQ9/Co4NijhrBZi+ v6dwxj8v2ZR/0wMsV4BDRnDz/Wh/Bb05Dm9WKWxGP39uYNDFhqrlIvD1ZU7lmJp+HUwq AJ5t9Kc7yYxQ1cK9KpYwM1HcKeHsIQeK9AcuwR+MtBsEO+1EHILs/5XrqLLeP4DWZKT3 6wDWAW5VmlQzMuNWjjdut2Ljqe6J+8dyE80wY1l9gjg31F6FozxhC+LgK+kHKOsjwohW 5UtQ== X-Gm-Message-State: AEkoouu10Dll5d6s+1KvekAAPLBHR0xMBxgQAY58opn3rUTiYs7eebVr3JoiB7oRLGieXw== X-Received: by 10.28.35.86 with SMTP id j83mr30640450wmj.18.1469623111931; Wed, 27 Jul 2016 05:38:31 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:56b5:0:ac27:b86c:7764:9429]) by smtp.gmail.com with ESMTPSA id p23sm6979002wme.8.2016.07.27.05.38.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jul 2016 05:38:31 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Date: Wed, 27 Jul 2016 14:38:12 +0200 Message-Id: <1469623097-26044-7-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1469623097-26044-1-git-send-email-daniel.vetter@ffwll.ch> References: <1469623097-26044-1-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH i-g-t 06/11] lib: Update docs for igt_stats 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-Virus-Scanned: ClamAV using ClamSMTP Unfortunately gtkdoc refuses to acknowledge static inlines, so need to nuke them. It probably gets confused by that static ... Also unamed unions confuse gtk-doc, move everything else public up. Cc: Chris Wilson Signed-off-by: Daniel Vetter --- lib/igt_stats.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_stats.h | 44 +++++++++++++++----------------------------- 2 files changed, 69 insertions(+), 29 deletions(-) diff --git a/lib/igt_stats.c b/lib/igt_stats.c index 78db6be11e7e..0fbf712c064d 100644 --- a/lib/igt_stats.c +++ b/lib/igt_stats.c @@ -606,3 +606,57 @@ double igt_stats_get_trimean(igt_stats_t *stats) igt_stats_get_quartiles(stats, &q1, &q2, &q3); return (q1 + 2*q2 + q3) / 4; } + +/** + * igt_mean_init: + * @m: tracking structure + * + * Initializes or resets @m. + */ +void igt_mean_init(struct igt_mean *m) +{ + memset(m, 0, sizeof(*m)); + m->max = -HUGE_VAL; + m->min = HUGE_VAL; +} + +/** + * igt_mean_add: + * @m: tracking structure + * @v: value + * + * Adds a new value @v to @m. + */ +void igt_mean_add(struct igt_mean *m, double v) +{ + double delta = v - m->mean; + m->mean += delta / ++m->count; + m->sq += delta * (v - m->mean); + if (v < m->min) + m->min = v; + if (v > m->max) + m->max = v; +} + +/** + * igt_mean_get: + * @m: tracking structure + * + * Computes the current mean of the samples tracked in @m. + */ +double igt_mean_get(struct igt_mean *m) +{ + return m->mean; +} + +/** + * igt_mean_get_variance: + * @m: tracking structure + * + * Computes the current variance of the samples tracked in @m. + */ +double igt_mean_get_variance(struct igt_mean *m) +{ + return m->sq / m->count; +} + diff --git a/lib/igt_stats.h b/lib/igt_stats.h index 32f376cc3032..5faeced4ccae 100644 --- a/lib/igt_stats.h +++ b/lib/igt_stats.h @@ -32,16 +32,17 @@ /** * igt_stats_t: * @values_u64: An array containing pushed integer values + * @is_float: Whether @values_f or @values_u64 is valid * @values_f: An array containing pushed float values * @n_values: The number of pushed values */ typedef struct { + unsigned int n_values; + unsigned int is_float : 1; union { uint64_t *values_u64; double *values_f; }; - unsigned int n_values; - unsigned int is_float : 1; /*< private >*/ unsigned int capacity; @@ -81,37 +82,22 @@ double igt_stats_get_median(igt_stats_t *stats); double igt_stats_get_variance(igt_stats_t *stats); double igt_stats_get_std_deviation(igt_stats_t *stats); +/** + * igt_mean: + * + * Structure to compute running statistical numbers. Needs to be initialized + * with igt_mean_init(). Read out data using igt_mean_get() and + * igt_mean_get_variance(). + */ struct igt_mean { + /*< private >*/ double mean, sq, min, max; unsigned long count; }; -static inline void igt_mean_init(struct igt_mean *m) -{ - memset(m, 0, sizeof(*m)); - m->max = -HUGE_VAL; - m->min = HUGE_VAL; -} - -static inline void igt_mean_add(struct igt_mean *m, double v) -{ - double delta = v - m->mean; - m->mean += delta / ++m->count; - m->sq += delta * (v - m->mean); - if (v < m->min) - m->min = v; - if (v > m->max) - m->max = v; -} - -static inline double igt_mean_get(struct igt_mean *m) -{ - return m->mean; -} - -static inline double igt_mean_get_variance(struct igt_mean *m) -{ - return m->sq / m->count; -} +void igt_mean_init(struct igt_mean *m); +void igt_mean_add(struct igt_mean *m, double v); +double igt_mean_get(struct igt_mean *m); +double igt_mean_get_variance(struct igt_mean *m); #endif /* __IGT_STATS_H__ */