Skip to Content.
Sympa Menu

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

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 (98697b770726aca716f7f7d41abab860fda54b7e)
  • Date: Wed, 25 Jun 2008 11:23:26 -0500

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

ChangeLog | 1
usr/sbin/gaze | 2 -
usr/share/man/man1/gaze.1 | 7 +++--
var/lib/sorcery/modules/libtime | 51
++++++++++++++++++++++++++++++++--------
4 files changed, 48 insertions(+), 13 deletions(-)

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}

compute_cast_times $spell |
case $type in
- --last)
- tail -n 1 ;;
- --median)
- compute_median ;;
- --mean)
- compute_mean ;;
+ --last)
+ tail -n 1 ;;
+ --median)
+ compute_median ;;
+ --mean)
+ compute_mean ;;
+ --weigh-last)
+ compute_weighted_mean last-cast $(private_installed_version $spell) ;;
esac
}

@@ -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

Archive powered by MHonArc 2.6.24.

Top of Page