File: 482

package info (click to toggle)
pcp 7.1.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,748 kB
  • sloc: ansic: 1,483,656; sh: 182,366; xml: 160,462; cpp: 83,813; python: 24,980; perl: 18,327; yacc: 6,877; lex: 2,864; makefile: 2,738; awk: 165; fortran: 60; java: 52
file content (136 lines) | stat: -rwxr-xr-x 3,718 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#! /bin/sh
# PCP QA Test No. 482
# exercise pmlogsummary "-B" option (display value distribution in bins)
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc.  All Rights Reserved.
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard filters
. ./common.product
. ./common.filter

status=1	# failure is the default!
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15

# usage: _xtract metric
_xtract()
{
    pmdumplog -Dpdu archives/binning $1 >$tmp.out 2>$tmp.err
    cat $tmp.err $tmp.out \
    | $PCP_AWK_PROG '
$1 == "__pmResult"                { state=1; time=$7; stamp=$6; next }
state == 1 && /\('"$1"'\)/      { state=2; next }
state == 2                      { state=0; print time,stamp,$2; next }
NF==0                           { state=0; next }' \
    | LC_COLLATE=POSIX _POSIX2_VERSION=0 sort -u +1n -2
}

# usage: _filterbins nbins < pmlogsummary output (with args=-ymMB nbins)
_filterbins()
{
    $PCP_AWK_PROG -v nbins=$1 '{
	printf "(%d)\n", $5
	for (i=0; i < nbins; i++)
	    printf "    Bin%d  = %d\n", i, $(7+(i*2))
    }'
}

# usage: _dobinning nbins min max < values
_dobinning()
{
    size=`echo "scale=10; ( $3 - $2 ) / $1" | bc`
    #echo BINSIZE=$size NBINS=$1

    $PCP_AWK_PROG -v nbins=$1 -v size=$size -v min=$2 '
	{   for (i=0; i < nbins; i++) {
		if ($1 >= (size*i) + min && $1 <= (size*(i+1))+min) {
		    #printf "%f is in bin %d\n", $1, i
		    bins[i]++
		    total++
		}
		#else
		#printf "%f out of %f-%f\n", $1, (size*i)+min, (size*(i+1))+min
	    }
	    #printf "value is %f\n", $1
	}
END	{   printf "(%d)\n", total
	    for (i=0; i < nbins; i++)
		printf "    Bin%d  = %d\n", i, bins[i]
	}'
}

_noncounter_values()
{
    $PCP_AWK_PROG '{
	    printf "%f\n", $3
	    if (count == 0 || $3 > max) max = $3
	    if (count == 0 || $3 < min) min = $3
	    count++
	    next
}
END	  { printf "COUNT=%d MAX=%f MIN=%f\n", count, max, min }'
}

_counter_values()
{
    $PCP_AWK_PROG '{
	    if (count > 0) {
		value = (($3 - prevval)/($2 - prevtime))/1000.0
		printf "%f\n", value
		if (count == 1 || value > max) max = value
		if (count == 1 || value < min) min = value
	    }
	    count++
	    prevval = $3
	    prevtime = $2
	    next
	  }
END	  { printf "COUNT=%d MAX=%f MIN=%f\n", count-1, max, min }'
}

# real QA test starts here
echo
echo "=== testing instanteous metric value distribution ==="
nbins=3
_xtract sample.scale_step.time_up_nanosecs | _noncounter_values > $tmp.noncount
eval `grep -F COUNT $tmp.noncount`
#echo count=$COUNT maximum=$MAX minimum=$MIN
$PCP_ECHO_PROG $PCP_ECHO_N "QA calculates: ""$PCP_ECHO_C"
grep -F -v COUNT $tmp.noncount | _dobinning $nbins $MIN $MAX

$PCP_ECHO_PROG $PCP_ECHO_N "pmlogsummary calculates: ""$PCP_ECHO_C"
pmlogsummary -ymMB $nbins archives/binning sample.scale_step.time_up_nanosecs \
	| _filterbins $nbins

echo
echo "=== testing counter metric value distribution ==="
nbins=4
_xtract sample.milliseconds | _counter_values > $tmp.count
eval `grep -F COUNT $tmp.count`
#echo count=$COUNT maximum=$MAX minimum=$MIN
$PCP_ECHO_PROG $PCP_ECHO_N "QA calculates: ""$PCP_ECHO_C"
grep -F -v COUNT $tmp.count | _dobinning $nbins $MIN $MAX

$PCP_ECHO_PROG $PCP_ECHO_N "pmlogsummary calculates: ""$PCP_ECHO_C"
pmlogsummary -ymMB $nbins archives/binning | grep -F sample.milliseconds \
	| _filterbins $nbins

# misc checks
echo
echo "=== testing boundary conditions ==="
pmlogsummary -B 1 archives/binning >/dev/null 2>&1
[ $? -ne 0 ] && echo "  urk - error test #1 failed!"
pmlogsummary -B 0 archives/binning >/dev/null 2>&1
[ $? -ne 0 ] && echo "  urk - error test #2 failed!"
pmlogsummary -B -7 archives/binning >/dev/null 2>&1
[ $? -eq 0 ] && echo "  urk - error test #3 failed!"

echo done.
echo

# success, all done
status=0
exit