Skip to Content.
Sympa Menu

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

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 (378feae52640a619ea43a422fccb0bb0a037ee46)
  • Date: Wed, 25 Jun 2008 07:24:42 -0500

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

ChangeLog | 6 +
usr/sbin/gaze | 57 +++++++++++++++-
usr/share/man/man1/gaze.1 | 5 +
var/lib/sorcery/modules/libsorcery | 2
var/lib/sorcery/modules/libtime | 131
+++++++++++++++++++++++++++++++++++++
5 files changed, 199 insertions(+), 2 deletions(-)

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

libsorcery: in verify_source print "failure" instead of the
unusual "failed"

commit 89024fcdc265603b52e705c6be65677491a2b0cc
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

gaze: added gaze time which shows the casting time of spells

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

libtime: added to hold functions dealing with time calculations

diff --git a/ChangeLog b/ChangeLog
index 97ab8de..9d18079 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-06-25 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
+ * libtime: added to hold functions dealing with time calculations
+ * gaze: added gaze time which shows the casting time of spells
+ * libsorcery: in verify_source print "failure" instead of the
+ unusual "failed"
+
2008-06-21 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* libqueue: reformatted push_queue and cleaned up pop_queue
formatting, coloring and spelling fixes in install_queue_history
diff --git a/usr/sbin/gaze b/usr/sbin/gaze
index 7bea2be..e7a5303 100755
--- a/usr/sbin/gaze
+++ b/usr/sbin/gaze
@@ -119,6 +119,11 @@ show-held Shows all held spells.

show-exiled Shows all exiled spells.

+time [--last|--median|--mean] spell
+ Shows previous spell cast time (without
summon)
+ and total time if more than one spell is
+ specified. Can also show median and mean
times.
+
EOF
}

@@ -2021,6 +2026,56 @@ function gaze_show_spells_by_status () {
message -n "${DEFAULT_COLOR}"
}

+#---------------------------------------------------------------------
+##
+## Display the time spells took to compile and install. If gaze is in
+## silent mode, pad all the times as needed.
+## @param Spell
+## @param ...
+##
+#---------------------------------------------------------------------
+function gaze_time() {
+
+ local diff time sum=0 spell type
+ if [[ $1 == -* ]]; then
+ type=$1
+ shift
+ fi
+
+ for spell in "$@"; do
+ diff=$(compute_cast_time $spell $type)
+ if [[ -z $diff ]]; then
+ message "${SPELL_COLOR}$spell$PROBLEM_COLOR wasn't cast yet at all!" \
+ "${DEFAULT_COLOR}"
+ continue
+ fi
+ (( sum += $diff ))
+
+ if [[ $GAZE_VERBOSE != 0 ]]; then
+ message -n "Casting ${SPELL_COLOR}$spell$DEFAULT_COLOR took "
+ time=$(date -u -d "1970-01-01 $diff seconds" "+%-Hh %-Mm")
+ if [[ "$time" == "0h 0m" ]]; then
+ echo "less than a minute."
+ else
+ echo $time
+ fi
+ else
+ echo -n "$spell:"
+ date -u -d "1970-01-01 $diff seconds" "+%Hh %Mm"
+ fi
+ done
+
+ if [[ -n $2 ]]; then
+ message -n "${MESSAGE_COLOR}Total time:$DEFAULT_COLOR "
+ if [[ $GAZE_VERBOSE != 0 ]]; then
+ date -u -d "1970-01-01 $sum seconds" "+%-Hh %-Mm"
+ else
+ date -u -d "1970-01-01 $sum seconds" "+%Hh %Mm"
+ fi
+ fi
+}
+
+
parse() {

# Maintain "TMP_DIR is always set as a global" invariant in the case of
@@ -2128,7 +2183,7 @@ parse() {
where) shift; gaze_show_where $@ ;;
size) shift; gaze_show_size $@ ;;
checkmd5s) shift; gaze_md5check $@ ;;
-
+ time) shift; gaze_time $@ ;;

compile) if [ -n "$3" ]; then
VERSION=$3
diff --git a/usr/share/man/man1/gaze.1 b/usr/share/man/man1/gaze.1
index 13dd4d7..8a71087 100644
--- a/usr/share/man/man1/gaze.1
+++ b/usr/share/man/man1/gaze.1
@@ -249,6 +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]
+.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
+spell is specified, also a total time is shown.
.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/libsorcery
b/var/lib/sorcery/modules/libsorcery
index 8fa561c..f4a3a90 100755
--- a/var/lib/sorcery/modules/libsorcery
+++ b/var/lib/sorcery/modules/libsorcery
@@ -952,7 +952,7 @@ function verify_source() { (
then
message "${PROBLEM_COLOR}Missing ${FILE_COLOR}${1}${DEFAULT_COLOR}"
message "${PROBLEM_COLOR}Cast aborting.${DEFAULT_COLOR}"
- activity_log "cast" "$SPELL" "$VERSION" "failed" \
+ activity_log "cast" "$SPELL" "$VERSION" "failure" \
"because it was missing source: $1"
return 1
fi
diff --git a/var/lib/sorcery/modules/libtime b/var/lib/sorcery/modules/libtime
new file mode 100644
index 0000000..2a74516
--- /dev/null
+++ b/var/lib/sorcery/modules/libtime
@@ -0,0 +1,131 @@
+#!/bin/bash
+#---------------------------------------------------------------------
+##
+## @Synopsis Set of functions used by gaze for time calculations
+## @Copyright (C) 2008 The Source Mage Team <http://www.sourcemage.org>
+##
+## This file holds various statistical functions and an interface to
+## the activity log for getting the input data.
+#---------------------------------------------------------------------
+
+#---------------------------------------------------------------------
+##
+## Computes all the casting times of the passed spell by inspecting
+## the activity log.
+##
+## @param spell
+## @param version (optional)
+##
+## @Stdout casting time(s)
+#---------------------------------------------------------------------
+function compute_cast_times() {
+ gawk -v spell=$1 -v version=$2 '
+ # log timestamps are in the "%Y%m%d:%H%M\(%z\)" format
(20080625:0853(+0000))
+ # we need them in "%Y %m %d %H %M %S" and %s (epoch time). We ignore the
+ # timezone, hoping the user does not change it while casting
+ function since_epoch(time, date) {
+ # The date:
+ date = substr(time,1,4) " " substr(time,5,2) " " substr(time,7,2)
+ # The time (use 00 for seconds):
+ date = date " " substr(time,10,2) " " substr(time,12,2) " 00"
+ return mktime(date)
+ }
+
+ /^.*\tcast\t.*\t.*\t.*\t.*$/ {
+ # check the spell and version manually - literally
+ if ($3 != spell) next
+ if (version != "" && $4 != version) next
+
+ # check all valid start/succes pairs
+ if ($5 == "start") {
+ start_time = $1
+ }
+ if ($5 == "success" && start_time != 0) {
+ succes_time = $1
+ print since_epoch(succes_time)-since_epoch(start_time)
+ start_time = 0
+ }
+ }' $ACTIVITY_LOG
+}
+
+#---------------------------------------------------------------------
+##
+## Display the time in seconds a spell took to compile and install.
+## @param spell
+## @Stdout cast time of spell in seconds
+#---------------------------------------------------------------------
+function compute_cast_time() {
+ local spell=$1 type=${2:---last}
+
+ compute_cast_times $spell |
+ case $type in
+ --last)
+ tail -n 1 ;;
+ --median)
+ compute_median ;;
+ --mean)
+ compute_mean ;;
+ esac
+}
+
+#---------------------------------------------------------------------
+##
+## Computes the mean of the passed arguments
+##
+## @Stdin numbers separeted by newlines
+## @Stdout mean value
+#---------------------------------------------------------------------
+function compute_mean() {
+ gawk '
+ BEGIN { n = 0 }
+
+ { sum += $0; n++ }
+
+ END {
+ if (n == 0) exit
+ print int(sum/n+0.5)
+ }'
+}
+
+#---------------------------------------------------------------------
+##
+## Computes the median of the passed arguments
+##
+## @Stdin numbers separeted by newlines
+## @Stdout median value
+#---------------------------------------------------------------------
+function compute_median() {
+ gawk '
+ BEGIN { n = 0 }
+
+ { numbers[n] = $0; n++ }
+
+ END {
+ if (n == 0) exit
+ if (n == 1) {
+ print numbers[0]
+ } else {
+ asort(numbers)
+ print (n % 2) ? numbers[int(n/2+1)] : (numbers[n/2] +
numbers[n/2+1])/2
+ }
+ }'
+}
+
+#---------------------------------------------------------------------
+## @License
+##
+## This software is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#---------------------------------------------------------------------



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

Archive powered by MHonArc 2.6.24.

Top of Page