Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
heroku-buildpack-nodejs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
heroku-buildpack-nodejs
Commits
f6840d14
Unverified
Commit
f6840d14
authored
Jan 24, 2019
by
Jeremy Morrell
Committed by
GitHub
Jan 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add timing function to build data module (#595)
* Add timing function to builddata module
parent
ecc54c1e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
build-data.sh
lib/build-data.sh
+10
-0
unit
test/unit
+12
-0
No files found.
lib/build-data.sh
View file @
f6840d14
...
@@ -17,6 +17,16 @@ bd_set() {
...
@@ -17,6 +17,16 @@ bd_set() {
kv_set
"
$BUILD_DATA_FILE
"
"
$1
"
"
$2
"
kv_set
"
$BUILD_DATA_FILE
"
"
$1
"
"
$2
"
}
}
# similar to mtime from stdlib
bd_time
()
{
local
key
=
"
$1
"
local
start
=
"
$2
"
local
end
=
"
${
3
:-$(
nowms
)}
"
local time
time
=
"
$(
echo
"
${
start
}
"
"
${
end
}
"
|
awk
'{ printf "%.3f", ($2 - $1)/1000 }'
)
"
kv_set
"
$BUILD_DATA_FILE
"
"
$key
"
"
$time
"
}
log_build_data
()
{
log_build_data
()
{
# print all values on one line in logfmt format
# print all values on one line in logfmt format
# https://brandur.org/logfmt
# https://brandur.org/logfmt
...
...
test/unit
View file @
f6840d14
...
@@ -166,6 +166,18 @@ testBuildData() {
...
@@ -166,6 +166,18 @@ testBuildData() {
# this isn't required, and this test serves as documentation
# this isn't required, and this test serves as documentation
bd_set
"a"
"this should come first"
bd_set
"a"
"this should come first"
assertEquals
"a=
\"
this should come first
\"
foo=
\"
value with spaces
\"
test=different-foo"
"
$(
log_build_data
)
"
assertEquals
"a=
\"
this should come first
\"
foo=
\"
value with spaces
\"
test=different-foo"
"
$(
log_build_data
)
"
# dates generated by running `nowms; sleep 10; nowms`
bd_time
"time"
"1545178120033"
"1545178130043"
assertEquals
"10.010"
"
$(
bd_get
time
)
"
# dates generated by running `nowms; sleep 1; nowms`
bd_time
"time"
"1545178503025"
"1545178504027"
assertEquals
"1.002"
"
$(
bd_get
time
)
"
# dates generated by running `nowms; sleep 30; nowms`
bd_time
"time"
"1545178521204"
"1545178551206"
assertEquals
"30.002"
"
$(
bd_get
time
)
"
}
}
testWebConcurrencyProfileScript
()
{
testWebConcurrencyProfileScript
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment