Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 200 lines (185 sloc) 5.437 kB
#!/bin/sh
# simple script to check the progress
gawk -- '
BEGIN {
index_count = 0
index_delta = 0
index_time = 0
elapsed_time = 0
start_time = 0
end_time = 0
delete parse_count
delete parse_delta
delete parse_time
delete parse_max
delete render_count
delete render_delta
delete render_max
quotes = "['"'"'\"]"
}
END {
if (0 != index_delta) {
printf("Index: %15d %8.2fs per %5d\n", index_count, (index_time / (index_count / index_delta)), index_delta)
} else {
print "Index: Not Started"
}
parse_complete = 0
if (0 != length(parse_count)) {
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
}
printf("Parse[%2d]: %11d %6.1f%% %8.2fs per %5d\n", i, parse_count[i], complete, average, parse_delta[i])
}
} else {
print "Parse: Not Started"
}
render_complete = 0
if (0 != length(render_count)) {
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
}
printf("Render[%2d]: %10d %6.1f%% %8.2fs per %5d\n", i, render_count[i], complete, average, render_delta[i])
}
} else {
print "Render: Not Started"
}
printf("Timed Makes: %s Parse: %d/%d Render: %d/%d\n",
seconds_to_string(elapsed_time),
parse_complete, length(parse_count),
render_complete, length(render_count))
if (end_time > 0) {
t = end_time - start_time
} else {
t = systime() - start_time
}
printf("Elapsed Time: %s\n", seconds_to_string(t))
}
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
render_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) {
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)
elapsed_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)
elapsed_time += first * 60 * 60 + minutes * 60 + seconds
} else {
elapsed_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 Complete
/^===>/ {
if (0 == start_time) {
start_time = mktime(gensub("[-:/]", " ", "g", $2 " " $3))
}
if ("Processing" == $5 && "Complete" == $6) {
end_time = mktime(gensub("[-:/]", " ", "g", $2 " " $3))
}
}
' "$@"
Jump to Line
Something went wrong with that request. Please try again.