From 5d93e2c01cc422d386cb00a011e11757edbd1500 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Tue, 8 Jan 2019 21:27:20 -0500 Subject: [PATCH] test-driver: Logs time taken for nests --- nixos/lib/test-driver/Logger.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nixos/lib/test-driver/Logger.pm b/nixos/lib/test-driver/Logger.pm index 3fe5ef67c144..080310ea34e0 100644 --- a/nixos/lib/test-driver/Logger.pm +++ b/nixos/lib/test-driver/Logger.pm @@ -4,6 +4,7 @@ use strict; use Thread::Queue; use XML::Writer; use Encode qw(decode encode); +use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC); sub new { my ($class) = @_; @@ -46,10 +47,12 @@ sub nest { print STDERR maybePrefix("$msg\n", $attrs); $self->{log}->startTag("nest"); $self->{log}->dataElement("head", $msg, %{$attrs}); + my $now = clock_gettime(CLOCK_MONOTONIC); $self->drainLogQueue(); eval { &$coderef }; my $res = $@; $self->drainLogQueue(); + $self->log(sprintf("(%.2f seconds)", clock_gettime(CLOCK_MONOTONIC) - $now)); $self->{log}->endTag("nest"); die $@ if $@; }