Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp265381rwo; Tue, 1 Aug 2023 16:54:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlHpzYVuRAI27WOBQ8y81/+OwZj7IGkJyXkg6O1nEBofVTaJJU3mM269ObOPV2c/I0hvG+xt X-Received: by 2002:a17:907:3e23:b0:98f:450e:fc20 with SMTP id hp35-20020a1709073e2300b0098f450efc20mr5207442ejc.17.1690934045133; Tue, 01 Aug 2023 16:54:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690934045; cv=none; d=google.com; s=arc-20160816; b=ilJRgAWWJhu6SExwjoAS6ervreDQa8tdPVBqwkwH5jU6JeNBQV+bPS+dzddfpqEHtK UWA7Iwckd+/CuSLh4jMTZtiitcMsi/Rww704mJPcrxBwSPQEpoAgA9Zzd3e94UBPBiMt U0d+ygTVsYcig7ri6DZRbewiN7NlOI+U4fDF9Z8LokmQstDKRhfOb4TwqunfSC4/fKke vKP2n9AJwLqz0rPxmvoKheze236VKOrGfxtBhxBtiIOG/Xx8QMAwm8YmOpTJJREMNXBT AqaGipGCy1+3cuAz8PExlXh3d6+GQWFjfCNlIxjPiUrdOUBVdADaWr72MOA1M41hdVc7 MRXw== 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=uhNC38rHJARy+Xjp7ygLG8chIPQNmXHx9lmwZL4Bu0s=; fh=V2LL5OuZUBGeSu6TXDWykcThOoazTGUpkln19rrO2KM=; b=KGM17pTC7JFRObBA6yl0JKMXrM5FPREisMvZHsrEWDmmP8H2+W+3RTrLpwhKryDb1z kUBb8Hg0EMdHg1Merfjyk+a77wtxmLK6Mg5SiDdm6EEamhMo+VZh66RLTzj6fmFO5DP0 D3R6MSF6qKIwmztiMSaFKy0WCCKyuuM65B8yO3HE0cJ4NW+sjzzr1F01W+QjH2EIhYpP y7dfn4yYFwSkpoG58fVS7IwoqrlMLxWh5TDruVCYjfwPaWgIoeQak+a6tJyF9slkh1sV rGEgs15LGdjK6pZrbKr9yg0K2JbQfIGDRrQSAZcDFIKo1ETwttA8IgsgOcBoYxvopJQ9 GkMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=UupK7Ns0; 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 f10-20020aa7d84a000000b0051e2486c1ecsi8628030eds.252.2023.08.01.16.53.41; Tue, 01 Aug 2023 16:54:05 -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=UupK7Ns0; 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 S229550AbjHAXcD (ORCPT + 99 others); Tue, 1 Aug 2023 19:32:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231153AbjHAXbx (ORCPT ); Tue, 1 Aug 2023 19:31:53 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12FD32690 for ; Tue, 1 Aug 2023 16:31:46 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-7909808a504so162915639f.1 for ; Tue, 01 Aug 2023 16:31:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690932705; x=1691537505; 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=uhNC38rHJARy+Xjp7ygLG8chIPQNmXHx9lmwZL4Bu0s=; b=UupK7Ns0o/fJJMAaRF8f1C4AW4nc2U5kf+qVlm990D2uRl+gauX4dffGp7/rqHwhlY aqoFEqoNPmO9Fhc6rX6nOHkYYEOS1cmdFlxBh8EMkOTLIbYfHAAlhF00MOLTObZAvyfV 9aPYOnzghd/Ubjh3Hkz0spbDiiNnZjuiG27g+vMdiWsF+9OOYZuxmYsraBLPW9kW4v9F Vw0ZuWgVFmlr7h0xZoKbZHzn6Ny2dD6zCIiRL2lItuamlEqc6WXdLyuJPO7MjMD3veac TZ+N0eEWwtL6FarggD5LEwm4OR/lebkR/oGRypwS5PB9zDZ42r1SXCM5to+yBUzfSmli /s4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690932705; x=1691537505; 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=uhNC38rHJARy+Xjp7ygLG8chIPQNmXHx9lmwZL4Bu0s=; b=NfXw6NcHU8zoPCDfKhQvCUpGgHhQhAVJFpb1lnqF28qc5l3CXzMI/+VQlrINjX/DHg tZI/cPzZU2B0c/A7jtOgHnszhjJhzctDSWCzq3d7/TVqVhnhpGT5ia4SI+hLAU3Jgk8a TschVPUAXcJ0xIWIH4BjAiMvGOiSNdmhQ39trERJx106YtWxaK8U1l6R9BZ7y7RkPF/X oYoFSgt+0iz2VhlstHXHEQvtJQa0WMBAKIkEQOp/ijNSjzyAP0LSysFZ4d8PXQdNK5rd Yjx8a4L1z7WFTG4WSFzQfreY66A+BZxQS38bJbOH3/785cQMHkc5I+NyKE21NqFVvRij 57yw== X-Gm-Message-State: ABy/qLasO/iz3wmTUKKaj+gFQdwZ4Is7p4sfcIpKzQSXJKUtFmv/HFkG +h1EtsTBNfQb0NgFnfisE63rGwrcpak= X-Received: by 2002:a5d:9e14:0:b0:790:a073:f122 with SMTP id h20-20020a5d9e14000000b00790a073f122mr9681659ioh.2.1690932704736; Tue, 01 Aug 2023 16:31:44 -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 d20-20020a5d9bd4000000b00790af7745b1sm1286269ion.20.2023.08.01.16.31.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Aug 2023 16:31:43 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [BlueZ PATCH v3 5/5] monitor/analyze: Inline data to gnuplot Date: Tue, 1 Aug 2023 16:31:35 -0700 Message-ID: <20230801233135.537864-5-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230801233135.537864-1-luiz.dentz@gmail.com> References: <20230801233135.537864-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 | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/monitor/analyze.c b/monitor/analyze.c index d0ad70d5dc74..9f882a6c8b71 100644 --- a/monitor/analyze.c +++ b/monitor/analyze.c @@ -112,35 +112,28 @@ 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, "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 +159,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