8000 minor #23972 [travis] Add timing info (nicolas-grekas) · symfony/symfony@3ba4112 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3ba4112

Browse files
minor #23972 [travis] Add timing info (nicolas-grekas)
This PR was merged into the 2.7 branch. Discussion ---------- [travis] Add timing info | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Let's see if this works. For reference, see https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/templates/header.sh Commits ------- 51d210e [travis] Add timing info
2 parents 2e286f8 + 51d210e commit 3ba4112

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

.travis.yml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,38 @@ before_install:
5151
export PHPUNIT_X="$PHPUNIT --exclude-group tty,benchmark,intl-data"
5252
export COMPOSER_UP='composer update --no-progress --no-suggest --ansi'
5353
54+
nanoseconds() {
55+
local cmd="date"
56+
local format="+%s%N"
57+
local os=$(uname)
58+
if hash gdate > /dev/null 2>&1; then
59+
cmd="gdate"
60+
elif [[ "$os" = Darwin ]]; then
61+
format="+%s000000000"
62+
fi
63+
$cmd -u $format
64+
}
65+
export -f nanoseconds
66+
5467
# tfold is a helper to create folded reports
5568
tfold () {
56-
title=$1
57-
fold=$(echo $title | sed -r 's/[^-_A-Za-z\d]+/./g')
69+
local title=$1
70+
local fold=$(echo $title | sed -r 's/[^-_A-Za-z0-9]+/./g')
5871
shift
59-
echo -e "travis_fold:start:$fold\\n\\e[1;34m$title\\e[0m"
60-
bash -xc "$*" 2>&1 &&
72+
local id=$(printf %08x $(( RANDOM * RANDOM )))
73+
local start=$(nanoseconds)
74+
echo -e "travis_fold:start:$fold"
75+
echo -e "travis_time:start:$id"
76+
echo -e "\\e[1;34m$title\\e[0m"
77+
78+
bash -xc "$*" 2>&1
79+
local ok=$?
80+
local end=$(nanoseconds)
81+
echo -e "\\ntravis_time:end:$id:start=$start,finish=$end,duration=$(($end-$start))"
82+
(exit $ok) &&
6183
echo -e "\\e[32mOK\\e[0m $title\\n\\ntravis_fold:end:$fold" ||
62-
( echo -e "\\e[41mKO\\e[0m $title\\n" && exit 1 )
84+
echo -e "\\e[41mKO\\e[0m $title\\n"
85+
(exit $ok)
6386
}
6487
export -f tfold
6588

0 commit comments

Comments
 (0)
0