Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 256 lines (239 sloc) 7.787 kb
#!/bin/sh
# this is -*- awk -*- code
# simple script to check the progress
# code executed by the shell, but ignored by gawk
# (awk concatenated string is true, but "&& 0" always evaluates to false
# to suppress the implied {print $0} on each match)
"test" "0" "=" "$#" && "exec" "gawk" "-f" "$0" && 0
"exec" "gawk" "-f" "$0" "--" "$@" && 0
# gawk code below this line
BEGIN {
index_count = 0
index_delta = 0
index_time = 0
timed_time = 0
start_time = 0
end_time = 0
delete parse_count
delete parse_delta
delete parse_time
delete parse_max
delete render_countq
delete render_delta
delete render_max
quotes = "['\"]"
normal_nl = "\033[0m\n"
completed = "\033[1;41;33m"
completion = "\033[1;33m"
timed = "\033[1;35m"
elapsed = "\033[1;32m"
}
END {
if (end_time > 0) {
elapsed_time = end_time - start_time
} else {
elapsed_time = systime() - start_time
}
if (0 != index_delta) {
printf("Index: %15d %s per %5d\n",
index_count,
seconds_to_string(index_time / (index_count / index_delta)),
index_delta)
} else {
print "Index: Not Started"
}
parse_complete = 0
if (0 != length(parse_count)) {
total_complete = 0
for (i in parse_count) {
if (0 == parse_max[i]) {
complete = 0
for (j in parse_max) {
if (0 != parse_max[j]) {
complete = 100 * parse_count[i] / parse_max[j]
break
}
}
} else {
complete = 100 * parse_count[i] / parse_max[i]
}
if (0 != parse_delta[i]) {
average = parse_time[i] / (parse_count[i] / parse_delta[i])
} else {
average = 0
}
if (100 == complete) {
parse_complete += 1
}
total_complete += complete
printf("Parse[%2d]: %11d %6.1f%% %s per %5d\n",
i, parse_count[i], complete,
seconds_to_string(average), parse_delta[i])
}
percent_complete = total_complete / length(parse_count)
if (0 == percent_complete) {
estimated_finish = "Unknown"
} else if (100 <= percent_complete) {
estimated_finish = "Complete"
} else {
estimated_finish = seconds_to_string(elapsed_time * (100 - percent_complete) / percent_complete)
}
printf((estimated_finish == "Complete" ? completed : completion) \
"Parsing Completion: %6.1f%% Estimated finish in: %s" normal_nl,
percent_complete, estimated_finish)
} else {
print "Parse: Not Started"
}
render_complete = 0
if (0 != length(render_count)) {
total_complete = 0
for (i in render_count) {
n = render_max[i]
if (0 == n) {
n = parse_count[i]
}
if (0 != n) {
complete = 100 * render_count[i] / n
} else {
complete = 0
}
if (0 != render_delta[i]) {
average = render_time[i] / (render_count[i] / render_delta[i])
} else {
average = 0
}
if (100 == complete) {
render_complete += 1
}
total_complete += complete
printf("Render[%2d]: %10d %6.1f%% %s per %5d\n",
i, render_count[i], complete,
seconds_to_string(average), render_delta[i])
}
c = length(parse_count)
if (c == 0 || c < length(render_count)) {
c = length(render_count)
}
percent_complete = total_complete / c
if (0 == percent_complete) {
estimated_finish = "Unknown"
} else if (100 <= percent_complete) {
estimated_finish = "Complete"
} else {
estimated_finish = seconds_to_string(elapsed_time * (100 - percent_complete) / percent_complete)
}
printf((estimated_finish == "Complete" ? completed : completion) \
"Rendering Completion: %6.1f%% Estimated finish in: %s" normal_nl,
percent_complete, estimated_finish)
} else {
print "Render: Not Started"
}
printf(timed "Timed Makes: %s Parse: %d/%d Render: %d/%d" normal_nl,
seconds_to_string(timed_time),
parse_complete, length(parse_count),
render_complete, length(render_count))
printf(elapsed "Elapsed Time: %s", seconds_to_string(elapsed_time))
if (0 != start_time && 0 != end_time) {
printf(elapsed " From: %s To: %s",
strftime("%Y-%m-%d %H:%M:%S", start_time),
strftime("%Y-%m-%d %H:%M:%S", end_time))
}
printf(normal_nl)
}
function seconds_to_string(elapsed_time, hours, minutes, seconds) {
minutes = int(elapsed_time / 60)
seconds = int(100 * (elapsed_time - minutes * 60)) / 100
hours= int(minutes / 60)
minutes -= hours * 60
return sprintf("%3d:%02d:%05.2f", hours, minutes, seconds)
}
/^Index:/ {
index_time += $2
n = $3
index_delta = n - index_count
index_count = n
}
/^make[[:space:]]+RENDER_BLOCK=.*parse/ {
n = gensub("^[^=]*=" quotes "*([[:digit:]]+)" quotes "*.*$", "\\1", "", $2) + 0
c = gensub("^[^=]*=" quotes "*([[:digit:]]+)" quotes "*.*$", "\\1", "", $4) + 0
sub("k", "000", c)
if ("all" == c) {
c = 0
}
parse_max[n] = c
}
/^Parse\[/ {
p1 = index($0, "-")
p2 = index($0, ".")
if (p1 > 0 && p2 > 0) {
i = substr($0, p1 + 1, p2 - p1 - 1)
if ("Total:" == $2) {
parse_count[i] = $3
parse_max[i] = $3
} else {
parse_time[i] += $2
n = $3
parse_delta[i] = n - parse_count[i]
parse_count[i] = n
}
}
}
/^Render\[/ {
p1 = index($0, "[")
p2 = index($0, "]")
if (p1 > 0 && p2 > 0) {
i = substr($0, p1 + 1, p2 - p1 - 1)
if ("Total:" == $2) {
if (0 != render_max[i]) {
render_count[i] = $3
}
render_max[i] = $3
} else {
render_time[i] += $2
n = $3
render_delta[i] = n - render_count[i]
render_count[i] = n
}
}
}
# extract elapsed time from the BASH internal time command, e.g.
# real 0m1.008s
# user 0m0.000s
# sys 0m0.010s
/^real/ {
t = $2
p1 = index(t, "m")
p2 = index(t, "s")
minutes = substr(t, 0, p1 - 1)
seconds = substr(t, p1 + 1, p2 - p1 - 1)
timed_time += minutes * 60 + seconds
}
# extract elapsed time from /usr/bin/time, e.g.
# 0.02user 0.00system 0:00.18elapsed 10%CPU (0avgtext+0avgdata 9664maxresident)k
# 31009.77user 989.92system 8:22:47elapsed 106%CPU (0avgtext+0avgdata 9733072maxresident)k
/^[[:digit:].]+user/ {
t = $3
p1 = index(t, ":")
p2 = index(t, "e")
first = substr(t, 0, p1 - 1)
t = substr(t, p1 + 1, p2 - p1 - 1)
p1 = index(t, ":")
if (p1 > 0) {
minutes = substr(t, 0, p1 - 1)
seconds = substr(t, p1 + 1)
timed_time += first * 60 * 60 + minutes * 60 + seconds
} else {
timed_time += first * 60 + t
}
}
# extract the start time, e.g.
# ===> 2010-06-21 18:16:04: git pull
# ===> 2010-06-21 18:16:04: echo Processing Completed
/^===>/ {
if (0 == start_time) {
start_time = mktime(gensub("[-:/]", " ", "g", $2 " " $3))
}
if ("Processing" == $5 && "Completed" == $6) {
end_time = mktime(gensub("[-:/]", " ", "g", $2 " " $3))
}
}
Jump to Line
Something went wrong with that request. Please try again.