unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] test/test-lib.sh: execute basename(1)s lazier in test_expect_equal_file ()
@ 2016-10-09 20:36 Tomi Ollila
  2016-10-26  1:04 ` David Bremner
  0 siblings, 1 reply; 3+ messages in thread
From: Tomi Ollila @ 2016-10-09 20:36 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

Moved the 2 basename(1) executions to the test failure branch in
test_expect_equal_file ().

The output of basename(1) executions in function test_expect_equal_file ()
are only used when tests fails -- when all tests pass these 2 basename(1)
executions are no longer done at all.
---
 test/test-lib.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index bda8a80..397408a 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -618,15 +618,15 @@ test_expect_equal_file ()
 	error "bug in the test script: not 2 or 3 parameters to test_expect_equal"
 
 	file1="$1"
-	basename1=`basename "$file1"`
 	file2="$2"
-	basename2=`basename "$file2"`
 	if ! test_skip "$test_subtest_name"
 	then
 		if diff -q "$file1" "$file2" >/dev/null ; then
 			test_ok_
 		else
 			testname=$this_test.$test_count
+			basename1=`basename "$file1"`
+			basename2=`basename "$file2"`
 			cp "$file1" "$testname.$basename1"
 			cp "$file2" "$testname.$basename2"
 			test_failure_ "$(diff -u "$testname.$basename1" "$testname.$basename2")"
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] test/test-lib.sh: execute basename(1)s lazier in test_expect_equal_file ()
  2016-10-09 20:36 [PATCH] test/test-lib.sh: execute basename(1)s lazier in test_expect_equal_file () Tomi Ollila
@ 2016-10-26  1:04 ` David Bremner
  2016-10-26 20:39   ` Tomi Ollila
  0 siblings, 1 reply; 3+ messages in thread
From: David Bremner @ 2016-10-26  1:04 UTC (permalink / raw)
  To: Tomi Ollila, notmuch; +Cc: tomi.ollila

Tomi Ollila <tomi.ollila@iki.fi> writes:

> Moved the 2 basename(1) executions to the test failure branch in
> test_expect_equal_file ().
>
> The output of basename(1) executions in function test_expect_equal_file ()
> are only used when tests fails -- when all tests pass these 2 basename(1)
> executions are no longer done at all.

I challenge you to measure the improvement; pushed to master anyway. ;)

d

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] test/test-lib.sh: execute basename(1)s lazier in test_expect_equal_file ()
  2016-10-26  1:04 ` David Bremner
@ 2016-10-26 20:39   ` Tomi Ollila
  0 siblings, 0 replies; 3+ messages in thread
From: Tomi Ollila @ 2016-10-26 20:39 UTC (permalink / raw)
  To: David Bremner, notmuch

On Wed, Oct 26 2016, David Bremner <david@tethera.net> wrote:

> Tomi Ollila <tomi.ollila@iki.fi> writes:
>
>> Moved the 2 basename(1) executions to the test failure branch in
>> test_expect_equal_file ().
>>
>> The output of basename(1) executions in function test_expect_equal_file ()
>> are only used when tests fails -- when all tests pass these 2 basename(1)
>> executions are no longer done at all.
>
> I challenge you to measure the improvement; pushed to master anyway. ;)

if 1 fork(2) takes 1 millisecond, then the full test suite runs 1 second
faster (+ some gain from dropping 500 execve(basename) calls).
So notmuch from execute time viewpoint.
(I actually happen to have suitable LD_PRELOAD library which could ne used
to measure execution times so I might accept the challenge ;D)

but this also reduces noise a bit when debugging test suite problems with 
`set -x` -- for human reader that is an improvement... there would be
somuch more to be improved there but oh well... ;/

Tomi

>
> d

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-10-26 20:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-09 20:36 [PATCH] test/test-lib.sh: execute basename(1)s lazier in test_expect_equal_file () Tomi Ollila
2016-10-26  1:04 ` David Bremner
2016-10-26 20:39   ` Tomi Ollila

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).