Prev: (Partially SOLVED) Re: Wireless still not working
Next: How to reduce a debian system to a base system
From: Ron Johnson on 29 Mar 2010 20:20 On 2010-03-29 16:35, Mike McClain wrote: [snip] > > Thanks a lot. Though my error was pointed out as a typo and corrected > a while back your solution using " date '+%s' " is much more elegant > than what I had done. If you want more (possibly too much) precision: $ date +'%s.%N' -- "History does not long entrust the care of freedom to the weak or the timid." Dwight Eisenhower -- To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org Archive: http://lists.debian.org/4BB14146.1060807(a)cox.net
From: Karl Vogel on 29 Mar 2010 21:30 Here's something I modified as part of a benchmark script called "fdtree". -- Karl Vogel I don't speak for the USAF or my company Dijkstra probably hates me. --Linus Torvalds, in kernel/sched.c #!/bin/bash # How to use xdate/xtime/persec: # # START=$(date "+%s") # count=10 # xdate # tin=$(xtime) # # # do something time-consuming $count times... # tout=$(xtime) # set $(persec $tin $tout $count); ttot=$1; results=$2 # xdate # echo "TIME IN, OUT, TOTAL = "$tin, $tout, $ttot # echo -e "\tWork per second = " $results PATH=/usr/local/bin:/bin:/usr/bin export PATH function xdate # Display the date in this form: Thu, 10 Sep 2009 21:22:06.494 { set $(date "+%a, %d %b %Y %T %N") ms=$(echo $6 | cut -c1-3) echo "$1 $2 $3 $4 $5.$ms" } function xtime # Display elapsed runtime to the millisecond. { set $(date "+%s %N") sec=$(($1 - $START)) ms=$(echo $2 | cut -c1-3) echo "$sec.$ms" } function persec # args: start-second, finish-second, count-things # returns elapsed time and things that happened per second # to the millisecond. { start=$1 finish=$2 count=$3 if test "$finish" = "$start"; then echo "0 0" else echo $(echo "scale=3; $finish-$start; $count/($finish-$start)" | bc) fi } function dbg # debugging prints { test $DEBUG -gt 0 && echo -e "$@" } tmp=/tmp/t1$$ tmp2=/tmp/t2$$ xdate START=$(date "+%s") tin=$(xtime) echo for k in 1 2 3 4 5 6 7 8 9 10 do # Read a short amount of random data. dd if=/dev/random of=$tmp2 bs=1k count=1 2> /dev/null # Duplicate it a bunch of times. cat $tmp2 $tmp2 $tmp2 $tmp2 $tmp2 $tmp2 $tmp2 $tmp2 > $tmp cat $tmp $tmp $tmp $tmp $tmp $tmp $tmp $tmp > $tmp2 cat $tmp2 $tmp2 $tmp2 $tmp2 $tmp2 $tmp2 $tmp2 $tmp2 > $tmp cat $tmp $tmp $tmp $tmp $tmp $tmp $tmp $tmp > $tmp2 cat $tmp2 $tmp2 $tmp2 $tmp2 $tmp2 $tmp2 $tmp2 $tmp2 > $tmp rm $tmp2 # Generate a hash. md5sum $tmp ls -l $tmp rm $tmp done echo count=10 tout=$(xtime) set $(persec $tin $tout $count); ttot=$1; results=$2 xdate echo "TIME IN, OUT, TOTAL = "$tin, $tout, $ttot echo -e "\tWork per second = " $results exit 0 -- To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org Archive: http://lists.debian.org/20100330012125.34BEBB7DB(a)bsd118.wpafb.af.mil
First
|
Prev
|
Pages: 1 2 3 Prev: (Partially SOLVED) Re: Wireless still not working Next: How to reduce a debian system to a base system |