bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] command: time


From: pourko
Subject: [PATCH] command: time
Date: Tue, 23 Sep 2025 04:53:04 +0200 (CEST)

Sometimes we would like to time the speed of some things for comparisons, 
but those things execute too fast to measure. So we arrange to put them
inside loops, and then measure the loops. That is not very practical, because
the loops in bash add too much overhead for the things we're trying to measure.
It would be much better if command time is modified to take an option -n N, 
N being how many times to execute the thing that is getting timed. That would
be much more efficient, and the measurement would be much more precise.

I looked into that, and it seems like adding a new option to the time command
would require changes to the source code that would be way too messy. So, the 
next best thing is controlling the time command behavior through a variable.

$ TIMEREPEAT=3;  time { ((x++)); echo $x;}
$ TIMEREPEAT=100000;  time true

Patch (apply with `patch -p0'):


Attachment: time.patch.txt
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]