New commits:
commit 98697b770726aca716f7f7d41abab860fda54b7e
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
libtime:
added weighted mean mode where the last version's timing counts 10 times
diff --git a/ChangeLog b/ChangeLog
index 5921a61..c9d80ed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
2008-06-25 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* libtime: added to hold functions dealing with time calculations
fixed a comment with a new insight
+ added weighted mean mode where the last version's timing counts 10
times
* gaze: added gaze time which shows the casting time of spells
* libsorcery: in verify_source print "failure" instead of the
unusual "failed"
diff --git a/usr/sbin/gaze b/usr/sbin/gaze
index e7a5303..9a6c0cc 100755
--- a/usr/sbin/gaze
+++ b/usr/sbin/gaze
@@ -119,7 +119,7 @@ show-held Shows all held spells.
show-exiled Shows all exiled spells.
-time [--last|--median|--mean] spell
+time [--last|--median|--mean|--weigh-last] spell(s)
Shows previous spell cast time (without
summon)
and total time if more than one spell is
specified. Can also show median and mean
times.
diff --git a/usr/share/man/man1/gaze.1 b/usr/share/man/man1/gaze.1
index 8a71087..255a415 100644
--- a/usr/share/man/man1/gaze.1
+++ b/usr/share/man/man1/gaze.1
@@ -249,10 +249,11 @@ If --fast is specified more limited output is produced,
but it runs much faster.
.IP
shows the spells that spell explicitly or recursively depends on.
Up to level $level if specified. The -c option skips trees that have already
been shown, the --no-optionals flag skips optional dependencies.
-.SS time [--last|--median|--mean] <spell> [spells]
+.SS time [--last|--median|--mean|--weigh-last] <spell> [spells]
.IP
-shows the time the spell(s) needed to get cast. By default the last cast time
-is shown, alternatively the median and mean can be shown. If more then one
+shows the time the spell(s) needed to get cast. By default the last casting
time
+is shown, alternatively the median, mean or weighted mean can be shown. The
+weighted mean mode gives more weight to the last casting time. If more then
one
spell is specified, also a total time is shown.
.SH "AUTHOR"
Original version written by Brian Peterson, modified by Kyle Sallee and
updated
diff --git a/var/lib/sorcery/modules/libtime b/var/lib/sorcery/modules/libtime
index 3cb9751..285e9fd 100755
--- a/var/lib/sorcery/modules/libtime
+++ b/var/lib/sorcery/modules/libtime
@@ -55,16 +55,20 @@ function compute_cast_times() {
## @Stdout cast time of spell in seconds
#---------------------------------------------------------------------
function compute_cast_time() {
- local spell=$1 type=${2:---last}
+ # FIXME: make the default configurable
+ local spell=$1
+ local type=${2:---last}
@@ -72,7 +76,7 @@ function compute_cast_time() {
##
## Computes the mean of the passed arguments
##
-## @Stdin numbers separeted by newlines
+## @Stdin numbers separated by newlines
## @Stdout mean value
#---------------------------------------------------------------------
function compute_mean() {
@@ -89,9 +93,38 @@ function compute_mean() {
#---------------------------------------------------------------------
##
+## Computes the weighted mean of the passed and some more arguments.
+## WARNING: only usable for cast times!
+##
+## @param type - weigh either just the times of the latest version
+##
+## @Stdin numbers separated by newlines
+## @Stdout mean value
+#---------------------------------------------------------------------
+function compute_weighted_mean() {
+ local type=$1
+ local version=$2
+
+ if [[ $type == last-cast ]]; then
+ local weight=10 #make this relative someday?
+ local i command
+ for ((i=1; i < $weight; i++)); do
+ command="p; $command"
+ done
+ {
+ # weigh the latest version by adding it another weight-1 times
+ # to the piped list of casting times of all versions
+ cat -
+ compute_cast_times $spell $version | sed -n "$command"
+ } | compute_mean
+ fi
+}
+
+#---------------------------------------------------------------------
+##
## Computes the median of the passed arguments
##
-## @Stdin numbers separeted by newlines
+## @Stdin numbers separated by newlines
## @Stdout median value
#---------------------------------------------------------------------
function compute_median() {
[SM-Commit] GIT changes to master sorcery by Jaka Kranjc (98697b770726aca716f7f7d41abab860fda54b7e),
Jaka Kranjc, 06/25/2008