File: optim_stats2.stp

package info (click to toggle)
systemtap 3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 32,860 kB
  • ctags: 12,513
  • sloc: cpp: 58,610; ansic: 58,189; exp: 37,322; sh: 10,633; xml: 7,771; perl: 2,252; python: 2,066; tcl: 1,305; makefile: 969; lisp: 105; java: 100; awk: 94; asm: 91; sed: 16
file content (96 lines) | stat: -rw-r--r-- 1,877 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
@define RANDCNT %( 4000 %)
@define RANDMAX %( 1000 %)
@define ITERS %( 1500 %)

@define time
%(
    %( runtime == "dyninst" %?
	gettimeofday_us()
    %:
	cpu_clock_us(cpu())
    %)
%)

@define feed(agg, tagg)
%(
    t = @time
    foreach(k in randvals)
	@agg <<< k
    @tagg += @time - t
%)

global x, tx = 0, y, ty = 0
global a, ta = 0, b, tb = 0
global randvals[@RANDCNT]

probe begin
{
    /* TEST 1: test optimizations for @count, @sum, @min, and @max. */

    for (i=0; i<@ITERS; i++)
    {

	for (j=0; j<@RANDCNT; j++)
	    randvals[j] = randint(@RANDMAX)

	/* The "ordering dance" described above happens here */
	if(i%2)
	{
	    @feed(x[1], tx)
	    @feed(y[1], ty)
	}
	else
	{
	    @feed(y[1], ty)
	    @feed(x[1], tx)
	}
    }

    /*
     * We need to print the stats out to avoid compiler elision.
     * The list of stats mentioned below makes the actual difference
     * between stats under test and is the gist of this test.  The test
     * should show no measurable shrinkage, if the below list doesn't
     * differ for measured stats.
     */
    printdln(" ", "IGNORE", @count(x[1]))
    printdln(" ", "IGNORE", @count(y[1]), @sum(y[1]), @min(y[1]), @max(y[1]))

    /*
     * Measured shrinkage [%], prevent division by zero caused by
     * rounding errors
     */
    printf("TEST3 %d\n", ((ty-tx)*10000)/(ty*100))


    /* TEST 2: test optimizations for @variance. */

    for (i=0; i<(@ITERS / 4); i++)
    {

	for (j=0; j<@RANDCNT; j++)
	    randvals[j] = randint(@RANDMAX)

	if(i%2)
	{
	    @feed(a[1], ta)
	    @feed(b[1], tb)
	}
	else
	{
	    @feed(b[1], tb)
	    @feed(a[1], ta)
	}
    }

    printdln(" ", "IGNORE", @count(a[1]))
    printdln(" ", "IGNORE", @variance(b[1]))

    /*
     * Measured shrinkage [%], prevent division by zero caused by
     * rounding errors
     */
    printf("TEST4 %d\n", ((tb-ta)*10000)/(tb*100))

    exit()
}