Re: [PATCH v3 7/8] trace2: add stopwatch timers
- From
- Jeff Hostetler <git@jeffhostetler.com>
- Date
- Oct 20, 2022, 20:52 UTC
- Message-ID
- <b7860e10-b174-2fb2-53eb-568686a961c4@jeffhostetler.com>
- In-Reply-To
- <xmqq7d0us0o2.fsf@gitster.g>
On 10/20/22 4:25 PM, Junio C Hamano wrote:
Show 26 quoted lines
> "Jeff Hostetler via GitGitGadget" <gitgitgadget@gmail.com> writes: > >> +#define NS_PER_SEC_D ((double)1000*1000*1000) >> ... >> + double t_total = ((double)timer->total_ns) / NS_PER_SEC_D; >> + double t_min = ((double)timer->min_ns) / NS_PER_SEC_D; >> + double t_max = ((double)timer->max_ns) / NS_PER_SEC_D; > > Hmph, it certainly is an improvement compared to the previous round, > but was there a reason why we did not want a more concise > > #define NS_TO_SECONDS(ns) ((double)(ns) / (1000*1000*1000.)) > > double t_total = NS_TO_SECONDS(timer->total_ns); > double t_min = NS_TO_SECONDS(timer->min_ns); > double t_max = NS_TO_SECONDS(timer->max_ns); > > that does not need to repeat (double) all over? > > Not worth a reroll by itself. Just wanted to know the reasoning > behind it, as I suspect I am missing the reason why it is good to > explicitly casting with (double) in some places; the above does not > look like one, though. > > Thanks. >
um, it never occurred to me to make it a macro with an arg. i just did a search/replace on the inline constant.
you're right though. your version is much shorter.
i'll reroll tomorrow with the typo that AEvar found.
Thanks Jeff