Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (24e42e85a8c64ed3ae67a93782c7cd996244c9f9)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Jaka Kranjc <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (24e42e85a8c64ed3ae67a93782c7cd996244c9f9)
  • Date: Sat, 5 Jul 2008 13:57:36 -0500

GIT changes to master sorcery by Jaka Kranjc <lynxlynxlynx AT sourcemage.org>:

ChangeLog | 4 +
usr/sbin/gaze | 13 ++++-
var/lib/sorcery/modules/libtime | 90
+++++++++++++++++++++++++++++++++++-----
3 files changed, 92 insertions(+), 15 deletions(-)

New commits:
commit 24e42e85a8c64ed3ae67a93782c7cd996244c9f9
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

only print time pairs of the same version in compute_cast_times

commit 26704f9e163e783cfeafd7d3ea3e29853791bc2f
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

also compute and print the total error

commit 915a8bc77959643a923c4f9464ad8d2b0c5b171e
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

made compute_mean also compute the estimation error, adapted libtime and
gaze to it and removed an extraneous space from pretty_print_time

the error is computed under the assumption of normality; like a sampling
error
with 95% confidence

diff --git a/ChangeLog b/ChangeLog
index 05f1c9a..982e23e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,7 +10,11 @@
* libtime, gaze: factored out a pretty_print_time function and
improved it
to not show 0 parts and incorporated the fix_zero_time in it
made use of pretty_print_time in other parts of the code
+ made compute_mean also compute the estimation error, adapted
libtime and
+ gaze to it and removed an extraneous space from pretty_print_time
+ also compute and print the total error
* libtime: removed the now unused fix_zero_time and epoch_to_hm
functions
+ only print time pairs of the same version in compute_cast_times

2008-07-04 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* libmisc: removed older, commented-out versions of
config_[gs]et_option
diff --git a/usr/sbin/gaze b/usr/sbin/gaze
index fd65095..0c226ba 100755
--- a/usr/sbin/gaze
+++ b/usr/sbin/gaze
@@ -2057,7 +2057,7 @@ function gaze_show_spells_by_status () {
#---------------------------------------------------------------------
function gaze_time() {

- local diff time sum=0 spell type
+ local diff time sum=0 err_sum=() n=0 spell type
if [[ $1 == -* ]]; then
type=$1
shift
@@ -2074,7 +2074,12 @@ function gaze_time() {
"${DEFAULT_COLOR}"
continue
fi
- (( sum += $diff ))
+ if [[ ${diff% *} == $diff ]]; then
+ (( sum += $diff ))
+ else
+ (( sum += ${diff% *}, n++ )) # we'll count the error separately
+ err_sum[n]=${diff#* }
+ fi

if [[ $GAZE_VERBOSE != 0 ]]; then
message -n "Casting ${SPELL_COLOR}$spell$DEFAULT_COLOR took "
@@ -2087,9 +2092,9 @@ function gaze_time() {
if [[ -n $2 ]]; then
message -n "${MESSAGE_COLOR}Total time:$DEFAULT_COLOR "
if [[ $GAZE_VERBOSE != 0 ]]; then
- pretty_print_time $sum
+ pretty_print_time $sum $(compute_total_error "${err_sum[@]}")
else
- echo $sum
+ echo $sum $(compute_total_error "${err_sum[@]}")
fi
fi
}
diff --git a/var/lib/sorcery/modules/libtime b/var/lib/sorcery/modules/libtime
index 2ccc35e..f7fa8ad 100755
--- a/var/lib/sorcery/modules/libtime
+++ b/var/lib/sorcery/modules/libtime
@@ -39,8 +39,9 @@ function compute_cast_times() {
# check all valid start/succes pairs
if ($5 == "start") {
start_time = $1
+ start_version = $4
}
- if ($5 == "success" && start_time != 0) {
+ if ($5 == "success" && start_time != 0 && start_version == $4) {
succes_time = $1
print since_epoch(succes_time)-since_epoch(start_time)
start_time = 0
@@ -75,7 +76,8 @@ function compute_cast_time() {
#---------------------------------------------------------------------
##
## Display the time in seconds a spell took to compile and install.
-## All known algorithms are used (see compute_cast_time).
+## All known algorithms are used (see compute_cast_time). Mean estimates
+## also show the estimation error.
##
## @param spell
## @param verbosity 0-machine readable/quiet
@@ -123,20 +125,25 @@ function compute_all_cast_times() {
}
#---------------------------------------------------------------------
##
-## Computes the mean of the passed arguments
+## Computes the mean of the passed arguments and its standard error
##
## @Stdin numbers separated by newlines
-## @Stdout mean value
+## @Stdout mean and its error
#---------------------------------------------------------------------
function compute_mean() {
gawk '
- BEGIN { n = 0 }
+ BEGIN { n = 0; mean = 0; variance = 0; }

- { sum += $0; n++ }
+ { sum += $0; numbers[n] = $0; n++ }

END {
if (n == 0) exit
- print int(sum/n+0.5)
+ mean = sum/n;
+ for (i in numbers) {
+ variance += (numbers[i] - mean)^2;
+ }
+
+ print int(mean+0.5), int(sqrt(variance/(n-1)/n)*1.96+0.5)
}'
}

@@ -195,12 +202,49 @@ function compute_median() {

#---------------------------------------------------------------------
##
-## Converts a time in seconds into a human readable format
+## Computes the combined error of independent variables
+##
+## @param error for each variable
+## @param ...
+## @Stdout total error
+#---------------------------------------------------------------------
+function compute_total_error() {
+ tr ' ' '\n' <<< "$@" |
+ gawk '
+ { total += $0^2 }
+
+ END {
+ print int(sqrt(total))
+ }'
+}
+
+#---------------------------------------------------------------------
+##
+## Converts a time in seconds and the estimation error (if available)
+## into a human readable format
##
## @param time in seconds
+## @param estimation error in seconds (optional)
## @Stdout time (DD:HH:MM or HH:MM or MM or "less than a minute")
#---------------------------------------------------------------------
function pretty_print_time() {
+ if [[ -z $2 ]]; then
+ pretty_print_time_sub "$@"
+ else
+ local time=$(pretty_print_time_sub $1)
+ echo -n "$time "
+ pretty_print_time_error $2
+ fi
+}
+
+#---------------------------------------------------------------------
+##
+## Converts a time in seconds into a human readable format.
+##
+## @param time in seconds
+## @Stdout time (DD:HH:MM or HH:MM or MM or "less than a minute")
+#---------------------------------------------------------------------
+function pretty_print_time_sub() {
# date can only print day of year starting with 1, so we can't use it,
# yet we have to display the number of days, since the total can be big
awk -v sum=$1 'END {
@@ -216,16 +260,40 @@ function pretty_print_time() {
exit
}
if (days > 0) {
- print days "d " hours "h " minutes "m "
+ print days "d " hours "h " minutes "m"
} else if (hours > 0) {
- print hours "h " minutes "m "
+ print hours "h " minutes "m"
} else {
- print minutes "m "
+ print minutes "m"
}
}' /dev/null
}

#---------------------------------------------------------------------
+##
+## Converts a time estimation error into a human readable format.
+## If the error is very small or 0, it isn't shown.
+##
+## @param estimation error in seconds
+## @Stdout time +/- error (see pretty_print_time)
+#---------------------------------------------------------------------
+function pretty_print_time_error() {
+ local error=$1
+
+ if (( $error < 60 )); then
+ error=0
+ else
+ error=$(pretty_print_time_sub $error)
+ fi
+
+ if [[ $error == 0 ]]; then
+ echo
+ else
+ echo "(+/- $error)"
+ fi
+}
+
+#---------------------------------------------------------------------
## @License
##
## This software is free software; you can redistribute it and/or modify



  • [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (24e42e85a8c64ed3ae67a93782c7cd996244c9f9), Jaka Kranjc, 07/05/2008

Archive powered by MHonArc 2.6.24.

Top of Page