Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp259275rwo; Tue, 1 Aug 2023 16:45:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlF/e9b/YkcM1Z1Qb5jTK2JTUXB91TNAB3nbPJlC+Giaqobuat3zfU+EUmURCppodjlG641v X-Received: by 2002:aa7:c3c6:0:b0:51e:4bd6:ce4a with SMTP id l6-20020aa7c3c6000000b0051e4bd6ce4amr3893284edr.11.1690933557664; Tue, 01 Aug 2023 16:45:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690933557; cv=none; d=google.com; s=arc-20160816; b=j0ueGci7UzS8E23lz05FuOQRdd1i5OtKCMbxyOax63QjC9bPmb68g0vLAVc/a53H+7 x5WfpLXeilTNEE6ZQCxeoIm3eLEMtE0E4xvoJG8OBA5YMYQaF5NzAidWTN/7hXEEU6Uz BGf3kAD+u+c1JMC7ZjfE25r98cGmY9A2pWOWYnfwEPw38F6IkTIP3yK4QO++UEvD+6/y Ap6K4Ps1E6+ClMjshkKri+Lww8yNgqsmD930innmtUTv/b3H+9N8D6M4dO5/W8s3VXkB GSAAfhhLMrhpO1cJDynup0IrViQcDiQd+Ml8C4qC9vQz5B4W3nldnYv9RQr9mOR/6XC9 j1mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=hhHzgYxpkySIP9sxo8gNiJ+G7DvpijjrVJOTxAgVnsM=; fh=V2LL5OuZUBGeSu6TXDWykcThOoazTGUpkln19rrO2KM=; b=oh3mx25YGoGGz5Q1D2fX4PRIbo7/x3wjG9ZC0yVQvq9R4R0iBj6zuKUKhCT4/qPrfs P5jt0iwipk/gqR8AorRiK4mKQcOnR/A9hWAdt/wrRZ6QKL2suIqSrWHs9y+Rm4aZ1/QQ 2SUepGLQ+LvcmU+FC8qIEli8FyjxXb4e1Xd832v4vg81ejZdDs+iwDDTulWNk8EuvI+F AuPfxViA/DD14YjX5xJLMEg/VgxkEKxrN7ZUcMht1CXJw6QXl6mI8rCAD/8N32DMZlHa nOeMGxwK+HjigbxKBpIAfGs9qPkyRyra9bOBxNTWW7HvMpHGql8FEqAPmY5Nx1c88e9e olbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=VhhRxqVS; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d19-20020a056402517300b005225a609054si5445996ede.291.2023.08.01.16.44.42; Tue, 01 Aug 2023 16:45:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=VhhRxqVS; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230036AbjHAXVx (ORCPT + 99 others); Tue, 1 Aug 2023 19:21:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230523AbjHAXVx (ORCPT ); Tue, 1 Aug 2023 19:21:53 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9968F26A6 for ; Tue, 1 Aug 2023 16:21:46 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-68706d67ed9so3897309b3a.2 for ; Tue, 01 Aug 2023 16:21:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690932105; x=1691536905; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=hhHzgYxpkySIP9sxo8gNiJ+G7DvpijjrVJOTxAgVnsM=; b=VhhRxqVSQs9zHULXPFJF4fvyucLWWYINw901Pl/fj8GPCvTJA/AXySVxY1uNUJW5TX ntJ/3mwoPJuaYL2Zz4m9PxP+nrYuRzJZamVwbVbnrQo5WJ7Ljyj4xnf/oli9mM+yuPHo x7mNaY9uweTPUslKaBIPgVJEri84weljEsOluzHs5qta9ZmFnKqtYw6JA6V3/yhrhxIq aKXUF+Wk25Ig6QZx6/u7sqWyMyyk1x8QbPTWa53ma7vCLvBgPrMkOuBFrrYrkEhDBhPN SySI9WkFKKGLBsH8dttkAkSQiyFQF5imbyg+GIAXbbeI/qInBHF3gJZas4HGhaTpXzGp xZiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690932105; x=1691536905; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hhHzgYxpkySIP9sxo8gNiJ+G7DvpijjrVJOTxAgVnsM=; b=Ko4PJatfy7YrOACn15zYT3HiLva90x37ANIopE6B623YqKeXHxqJ2aBTydIAl3SV/G FouWK0cYjmwlhQx60LijvCk7cp6RLJaksmq2x9f1DNrpDH3caWXj/sAtT74IVzM3kapr Mfd4jCI3SqCvPxxnlejGsSuPaiCjh3JPCMMqXc7in8J+iIPhWeiic4RevenSh+KxQKlv /KyIqKo4l6ZPswTcTWheacnb2fdp9Ej1iSVhVON8GZ0STTgRprgxRvpLDa0Q04y5synR RRsDQ+YVGtRtdViPPDFXS4yiH/HmEG0J4NFRWK69YwuuwNWlBfXwdDJTWmduztsCt9KJ /l0A== X-Gm-Message-State: ABy/qLYsc/BLu5K/bZx/bmg2IprmItqpMeFoJ4oZsVUFv/nZDxF4lyhF fAuSGHA4zMuSl3cHqvJerYylHqJO/IU= X-Received: by 2002:a05:6a20:a108:b0:13e:23bc:f4cc with SMTP id q8-20020a056a20a10800b0013e23bcf4ccmr6011708pzk.37.1690932105404; Tue, 01 Aug 2023 16:21:45 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-236-201-58.hsd1.or.comcast.net. [71.236.201.58]) by smtp.gmail.com with ESMTPSA id fk25-20020a056a003a9900b00682a8e600f0sm9856157pfb.35.2023.08.01.16.21.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Aug 2023 16:21:44 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [BlueZ PATCH v2 5/5] monitor/analyze: Inline data to gnuplot Date: Tue, 1 Aug 2023 16:21:35 -0700 Message-ID: <20230801232135.535733-5-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230801232135.535733-1-luiz.dentz@gmail.com> References: <20230801232135.535733-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz Instead of creating a separate file just to write the x:y axis inline the data via gnuplot $data variable then use it to plot. --- monitor/analyze.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/monitor/analyze.c b/monitor/analyze.c index d0ad70d5dc74..687595cb249a 100644 --- a/monitor/analyze.c +++ b/monitor/analyze.c @@ -112,35 +112,29 @@ static void tmp_write(void *data, void *user_data) static void plot_draw(struct queue *queue) { - const char *filename = "analyze.tmp"; - FILE *gplot = popen("gnuplot", "w"); - FILE *tmp; + FILE *gplot; + if (queue_length(queue) < 2) + return; + + gplot = popen("gnuplot", "w"); if (!gplot) return; - if (queue_isempty(queue)) - goto done; - - tmp = fopen(filename, "w"); - if (!tmp) - goto done; - - queue_foreach(queue, tmp_write, tmp); + fprintf(gplot, "$data << EOD\n"); + queue_foreach(queue, tmp_write, gplot); + fprintf(gplot, "EOD\n"); fprintf(gplot, "set terminal dumb enhanced ansi\n"); fprintf(gplot, "set xlabel 'Latency (ms)'\n"); fprintf(gplot, "set tics out nomirror\n"); fprintf(gplot, "set log y\n"); fprintf(gplot, "set yrange [0.5:*]\n"); - fprintf(gplot, "plot './%s' using 1:2 t 'Packets' w impulses\n", - filename); + fprintf(gplot, "set log y\n"); + fprintf(gplot, "plot $data using 1:2 t 'Packets' w impulses\n"); fflush(gplot); - fclose(tmp); -done: pclose(gplot); - unlink(filename); } static void chan_destroy(void *data) @@ -166,8 +160,7 @@ static void chan_destroy(void *data) print_field("~%lld Kb/s TX transfer speed", chan->tx_bytes * 8 / TV_MSEC(chan->tx_l.total)); - if (chan->num > 1) - plot_draw(chan->plot); + plot_draw(chan->plot); free(chan); } -- 2.41.0