This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] benchtests: Improve readability of JSON output
- From: Will Newton <will dot newton at linaro dot org>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: libc-alpha <libc-alpha at sourceware dot org>
- Date: Tue, 8 Apr 2014 11:15:34 +0100
- Subject: Re: [PATCH] benchtests: Improve readability of JSON output
- Authentication-results: sourceware.org; auth=none
- References: <1396949290-21346-1-git-send-email-will dot newton at linaro dot org> <5343C311 dot 1030101 at redhat dot com>
On 8 April 2014 10:36, Florian Weimer <fweimer@redhat.com> wrote:
> On 04/08/2014 11:28 AM, Will Newton wrote:
>
>> +void
>> +json_attr_double (json_ctx_t *ctx, const char *name, double d)
>> +{
>> + if (!ctx->first_element)
>> + {
>> + fprintf (ctx->fp, ",\n");
>> + }
>> +
>> + ctx->first_element = false;
>> +
>> + do_indent (ctx);
>> +
>> + fprintf (ctx->fp, "\"%s\": %g", name, d);
>> +}
>
>
> Since you posted this, I have to ask: Is there are concise way to implement
> this correctly, preserving the actual value of d in the output?
Not to my knowledge. I guess it wouldn't hurt to increase the
precision a bit though. Either way there are going to be values we
cannot support such as NaN and Inf.
> Getting this right is quite a challenge for other (real) JSON libraries.
> They are also affected by the locale issue.
Luckily we don't need to be 100% general here and we have quite a
narrow use case. The code currently behaves exactly as it did before
the library code was extracted out so this patch does not actually
change behaviour. If we find we need multiple API functions to do
specific output formats for different purposes within the benchmarks
then I don't see that as a big problem.
--
Will Newton
Toolchain Working Group, Linaro