git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, Christian Couder <chriscool@tuxfamily.org>
Subject: Re: [PATCH] t/perf: depend on perl JSON only when using --codespeed
Date: Wed, 24 Apr 2019 10:20:12 +0900	[thread overview]
Message-ID: <xmqqd0lc42sz.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20190423043419.GA11689@sigill.intra.peff.net> (Jeff King's message of "Tue, 23 Apr 2019 00:34:20 -0400")

Jeff King <peff@peff.net> writes:

> Commit 05eb1c37ed (perf/aggregate: implement codespeed JSON output,
> 2018-01-05) added a dependency on the perl JSON module to show output
> from aggregate.perl, but we only need it when the user asks for
> --codespeed output. While the module is pretty common, it's not part of
> the base system, and this dependency can get in the way of producing the
> default human-readable output.
>
> Let's bump the "use" down to a "require" in the code path that needs it,
> which will be interpreted at run-time instead of compile-time. People
> not using "--codespeed" won't even load the module, and anybody using it
> should see the same results (including the same perl error if they don't
> have it).

Nice.

> This bites me occasionally when running perf tests on many-core work
> machines where I can't just "apt-get install libjson-perl". So I finally
> decided look into it. :)

Thanks.

>  t/perf/aggregate.perl | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/t/perf/aggregate.perl b/t/perf/aggregate.perl
> index 494907a892..76dd48f890 100755
> --- a/t/perf/aggregate.perl
> +++ b/t/perf/aggregate.perl
> @@ -3,7 +3,6 @@
>  use lib '../../perl/build/lib';
>  use strict;
>  use warnings;
> -use JSON;
>  use Getopt::Long;
>  use Git;
>  
> @@ -342,7 +341,8 @@ sub print_codespeed_results {
>  		}
>  	}
>  
> -	print to_json(\@data, {utf8 => 1, pretty => 1, canonical => 1}), "\n";
> +	require JSON;
> +	print JSON::to_json(\@data, {utf8 => 1, pretty => 1, canonical => 1}), "\n";
>  }
>  
>  binmode STDOUT, ":utf8" or die "PANIC on binmode: $!";

      reply	other threads:[~2019-04-24  1:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-23  4:34 [PATCH] t/perf: depend on perl JSON only when using --codespeed Jeff King
2019-04-24  1:20 ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqd0lc42sz.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).