Permalink
Browse files

add script from das 70

  • Loading branch information...
garybernhardt committed Jun 16, 2012
1 parent c9f063e commit f82e520f45f2f0b2110548ec5eab9362a8693f1d
Showing with 38 additions and 0 deletions.
  1. +38 −0 das-0070-time-to-first-request/time_to_first_request.sh
@@ -0,0 +1,38 @@
#!/bin/bash
main() {
print_runtime > /dev/null
print_runtime
}
print_runtime() {
pid=$(start_server)
runtime=$(time_command wait_for_server)
baseline=$(time_command wait_for_server)
echo $runtime - $baseline | bc
kill -9 $pid
}
start_server() {
cd example
rackup >/dev/null 2>&1 &
echo $!
}
time_command() {
local cmd=$*
TIMEFORMAT="%3R"
(time $cmd) 2>&1
}
wait_for_server() {
while true; do
lsof -i :9292 > /dev/null
if [[ $? == 0 ]]; then
break
fi
done
}
main

0 comments on commit f82e520

Please sign in to comment.