[LEDE-DEV] [PATCH] procd: add timing to start/stop logging

John Crispin john at phrozen.org
Wed Jan 17 01:04:14 PST 2018



On 16/01/18 10:49, Karl Vogel wrote:
> Shows how long an initd task took, for example:
>
>   procd: stop /etc/init.d/dropbear running - took 0.088824 us
>   procd: Update service dnsmasq
>   procd: Update instance dnsmasq::dnsmasq
>   procd: running /etc/init.d/dnsmasq running
>   procd: start /etc/init.d/dnsmasq running
>   procd: stop /etc/init.d/dnsmasq running - took 0.092586 us
Hi Karl,

nitpicks inline...

> Signed-off-by: Karl Vogel <karl.vogel at gmail.com>
> ---
>   rcS.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/rcS.c b/rcS.c
> index dd3b76d..59c9038 100644
> --- a/rcS.c
> +++ b/rcS.c
> @@ -37,6 +37,7 @@ static struct runqueue q, r;
>   struct initd {
>   	struct ustream_fd fd;
>   	struct runqueue_process proc;
> +	struct timeval tstart;

call it tv_start please

>   	char *file;
>   	char *param;
>   };
> @@ -70,6 +71,7 @@ static void q_initd_run(struct runqueue *q, struct runqueue_task *t)
>   	int pipefd[2];
>   	pid_t pid;
>   
> +	gettimeofday(&s->tstart, NULL);
>   	DEBUG(2, "start %s %s \n", s->file, s->param);
>   	if (pipe(pipefd) == -1) {
>   		ERROR("Failed to create pipe: %m\n");
> @@ -106,8 +108,11 @@ static void q_initd_run(struct runqueue *q, struct runqueue_task *t)
>   static void q_initd_complete(struct runqueue *q, struct runqueue_task *p)
>   {
>   	struct initd *s = container_of(p, struct initd, proc.task);
> +	struct timeval tstop, tres;

tv_stop and tv_res

>   
> -	DEBUG(2, "stop %s %s \n", s->file, s->param);
> +	gettimeofday(&tstop, NULL);
> +	timersub(&tstop, &s->tstart, &tres);
> +	DEBUG(2, "stop %s %s - took %lu.%06lu us\n", s->file, s->param, tres.tv_sec, tres.tv_usec);

the unit should be seconds and not usecs ?!

     John


>   	ustream_free(&s->fd.stream);
>   	close(s->fd.fd.fd);
>   	free(s);




More information about the Lede-dev mailing list