Skip to content

Commit 7e173e2

Browse files
committed
askrene: add runtime of getroutes to the logs
Add log information about the runtime of getroutes. Changelog-None: askrene: add runtime of getroutes to the logs Signed-off-by: Lagrang3 <[email protected]>
1 parent 0e7615b commit 7e173e2

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

plugins/askrene/askrene.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,12 @@ static struct amount_msat linear_flows_cost(struct flow **flows,
348348
return total;
349349
}
350350

351+
static u64 time_delta_ms(struct timerel t)
352+
{
353+
u64 msec = t.ts.tv_sec * 1000 + t.ts.tv_nsec / 1000000;
354+
return msec;
355+
}
356+
351357
/* Returns an error message, or sets *routes */
352358
static const char *get_routes(const tal_t *ctx,
353359
struct command *cmd,
@@ -373,6 +379,8 @@ static const char *get_routes(const tal_t *ctx,
373379
double delay_feefactor;
374380
u32 mu;
375381
const char *ret;
382+
struct timerel time_delta;
383+
struct timemono time_start = time_mono();
376384

377385
if (gossmap_refresh(askrene->gossmap)) {
378386
/* FIXME: gossmap_refresh callbacks to we can update in place */
@@ -586,14 +594,19 @@ static const char *get_routes(const tal_t *ctx,
586594
}
587595

588596
gossmap_remove_localmods(askrene->gossmap, localmods);
589-
597+
time_delta = timemono_between(time_mono(), time_start);
598+
rq_log(tmpctx, rq, LOG_INFORM, "get_routes completed in %" PRIu64 " ms",
599+
time_delta_ms(time_delta));
590600
return NULL;
591601

592602
/* Explicit failure path keeps the compiler (gcc version 12.3.0 -O3) from
593603
* warning about uninitialized variables in the caller */
594604
fail:
595605
assert(ret != NULL);
596606
gossmap_remove_localmods(askrene->gossmap, localmods);
607+
time_delta = timemono_between(time_mono(), time_start);
608+
rq_log(tmpctx, rq, LOG_INFORM, "get_routes failed after %" PRIu64 " ms",
609+
time_delta_ms(time_delta));
597610
return ret;
598611
}
599612

0 commit comments

Comments
 (0)