Skip to Content.
Sympa Menu

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

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 (ce4500f937f2c842d5fc80c84b604f234b8b0808)
  • Date: Wed, 25 Jun 2008 14:47:50 -0500

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

ChangeLog | 2 +
usr/sbin/gaze | 29 ++++++++++++++
usr/share/man/man1/gaze.1 | 4 +-
var/lib/sorcery/modules/libtime | 78
++++++++++++++++++++++++++++++++++++++++
4 files changed, 112 insertions(+), 1 deletion(-)

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

gaze:
added time --full, which prints all the casting times we can compute

commit 85a4bf5d715809eab1cf663db1bbd0c8cce3e111
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

libtime:
added compute_all_cast_times for use in gaze and two helper functions

diff --git a/ChangeLog b/ChangeLog
index c9d80ed..383f08b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,9 @@
* 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
+ added compute_all_cast_times for use in gaze and two helper
functions
* gaze: added gaze time which shows the casting time of spells
+ added time --full, which prints all the casting times we can compute
* libsorcery: in verify_source print "failure" instead of the
unusual "failed"

diff --git a/usr/sbin/gaze b/usr/sbin/gaze
index 9a6c0cc..cb6acc2 100755
--- a/usr/sbin/gaze
+++ b/usr/sbin/gaze
@@ -123,6 +123,9 @@ 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.
+time --full spell(s)
+ Shows previous spell cast time (without
summon)
+ computed in (all) different manners (see
above)

EOF
}
@@ -2040,6 +2043,10 @@ function gaze_time() {
if [[ $1 == -* ]]; then
type=$1
shift
+ if [[ $type == --full ]]; then
+ gaze_time_full "$@"
+ return
+ fi
fi

for spell in "$@"; do
@@ -2075,6 +2082,28 @@ function gaze_time() {
fi
}

+#---------------------------------------------------------------------
+##
+## Display the time spells took to compile and install. If gaze is in
+## silent mode, pad all the times as needed. Prints all the available
+## times.
+##
+## @param Spell
+## @param ...
+##
+#---------------------------------------------------------------------
+function gaze_time_full() {
+ local spell
+
+ for spell in "$@"; do
+ compute_all_cast_times $spell $GAZE_VERBOSE
+ if [[ $? != 0 ]]; then
+ message "${SPELL_COLOR}$spell$PROBLEM_COLOR wasn't cast yet at all!" \
+ "${DEFAULT_COLOR}"
+ continue
+ fi
+ done
+}

parse() {

diff --git a/usr/share/man/man1/gaze.1 b/usr/share/man/man1/gaze.1
index 255a415..050c1c0 100644
--- a/usr/share/man/man1/gaze.1
+++ b/usr/share/man/man1/gaze.1
@@ -249,12 +249,14 @@ 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|--weigh-last] <spell> [spells]
+.SS time [--last|--median|--mean|--weigh-last|--full] <spell> [spells]
.IP
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.
+.IP
+If --full is specified, then all the calculations will be shown for each
spell.
.SH "AUTHOR"
Original version written by Brian Peterson, modified by Kyle Sallee and
updated
by Thomas Stewart and Karsten Behrmann
diff --git a/var/lib/sorcery/modules/libtime b/var/lib/sorcery/modules/libtime
index 285e9fd..f2a1980 100755
--- a/var/lib/sorcery/modules/libtime
+++ b/var/lib/sorcery/modules/libtime
@@ -74,6 +74,52 @@ 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).
+##
+## @param spell
+## @param verbosity 0-machine readable/quiet
+## @Stdout pretty-printed cast times of spell
+## @return 1 if there are no valid times available
+## @return 0 otherwise
+#---------------------------------------------------------------------
+function compute_all_cast_times() {
+ local spell=$1 verbosity=$2
+ local times time
+
+ times=$(compute_cast_times $spell)
+ [[ -z $times ]] && return 1
+
+ if [[ $verbosity == 0 ]]; then
+ echo $spell
+ echo "$times" | tail -n 1
+ echo "$times" | compute_median
+ echo "$times" | compute_mean
+ echo "$times" | compute_weighted_mean last-cast
$(private_installed_version $spell)
+ echo
+ else
+ message -n "Last cast time of ${SPELL_COLOR}$spell$DEFAULT_COLOR: "
+ time=$(echo "$times" | tail -n 1)
+ fix_zero_time "$(epoch_to_hm $time)"
+
+ message -n "Median cast time of ${SPELL_COLOR}$spell$DEFAULT_COLOR: "
+ time=$(echo "$times" | compute_median)
+ fix_zero_time "$(epoch_to_hm $time)"
+
+ message -n "Mean cast time of ${SPELL_COLOR}$spell$DEFAULT_COLOR: "
+ time=$(echo "$times" | compute_mean)
+ fix_zero_time "$(epoch_to_hm $time)"
+
+ message -n "Weighted mean cast time of
${SPELL_COLOR}$spell$DEFAULT_COLOR: "
+ time=$(echo "$times" | compute_weighted_mean last-cast
$(private_installed_version $spell))
+ fix_zero_time "$(epoch_to_hm $time)"
+ echo
+ fi
+
+ return 0
+}
+#---------------------------------------------------------------------
+##
## Computes the mean of the passed arguments
##
## @Stdin numbers separated by newlines
@@ -145,6 +191,38 @@ function compute_median() {
}

#---------------------------------------------------------------------
+##
+## Converts a time in seconds since the epoch to HH MM
+##
+## @param seconds
+## @param padding - if set will pad times with 0
+## @Stdout time
+#---------------------------------------------------------------------
+function epoch_to_hm() {
+ if [[ -z $2 ]]; then
+ date -u -d "1970-01-01 $1 seconds" "+%-Hh %-Mm"
+ else
+ date -u -d "1970-01-01 $1 seconds" "+%Hh %Mm"
+ fi
+}
+
+#---------------------------------------------------------------------
+##
+## Converts a time of "0h 0m" to an english string
+##
+## @param time
+## @Stdout possibly fixed time
+#---------------------------------------------------------------------
+function fix_zero_time() {
+ local time=$1
+ if [[ $time == "0h 0m" ]]; then
+ echo "less than a minute."
+ else
+ echo $time
+ fi
+}
+
+#---------------------------------------------------------------------
## @License
##
## This software is free software; you can redistribute it and/or modify



  • [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (ce4500f937f2c842d5fc80c84b604f234b8b0808), Jaka Kranjc, 06/25/2008

Archive powered by MHonArc 2.6.24.

Top of Page