From f2b41d540ae0a5af3df0ae001c295651c8916ae9 Mon Sep 17 00:00:00 2001 From: xonix Date: Mon, 27 Sep 2021 01:58:30 +0300 Subject: [PATCH] Use gawk's `gettimeofday` if available #57 --- .github/workflows/run-tests.yml | 2 +- README.md | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 1cc6888..0df7a6d 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -39,7 +39,7 @@ jobs: - name: "run tests" run: | - brew install gawk + brew install gawk # TODO understand if this step can be cached ./makesure_stable win: diff --git a/README.md b/README.md index 20337e7..d8278de 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,34 @@ Valid options: `timing`, `tracing`, `silent` ``` @options timing ``` -Will measure and log each goal execution time + total time. +Will measure and log each goal execution time + total time. + +Example `Makesurefile`: +``` +@options timing + +@goal a +@depends_on b + echo "Executing goal 'a' ..." + sleep 1 +@goal b + echo "Executing goal 'b' ..." + sleep 2 +``` + +Running: +``` +$ ./makesure a + goal 'b' ... +Executing goal 'b' ... + goal 'b' took 2.003 s + goal 'a' ... +Executing goal 'a' ... + goal 'a' took 1.003 s + total time 3.006 s +``` + +*Small issue exists with this option on macOS.* Due to BSD `date` not supporting `+%N` formatting option the default precision of timings is 1 sec. To make it 1 ms precise (if this is important) just install Gawk (`brew install gawk`). In this case Gawk built-in `gettimeofday` function will be used. ``` @options tracing ```