File: optim_stats.stp

package info (click to toggle)
systemtap 5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,556 kB
  • sloc: cpp: 81,117; ansic: 54,933; xml: 49,795; exp: 43,595; sh: 11,526; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (64 lines) | stat: -rw-r--r-- 1,460 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
#! /usr/bin/env stap

# this many complete test iterations
@define ITERCNT %( 10 %)
# this many <<< operations per batch, before checking time
@define BATCH %( 65536 %)
# this many microseconds total to run batches for
@define BATCHTIME %( 50000 %)

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

@define feed(agg, nagg)
%(
    t1 = @time
    cnt = 0
    while (1)
    {
        cnt++
        if (cnt % @BATCH == 0) # ensure we don't call time functions so frequently that they outweigh the payload
           if (@time > (t1 + @BATCHTIME)) break
        @agg <<< cnt # This is the operation whose runtime we actually want to measure!
    }
    @nagg = @nagg + cnt
%)

global a, na = 0
global b, nb = 0
global c, nc = 0
global d, nd = 0

probe begin
{
    for (i=0; i<@ITERCNT; i++)
    {
            @feed(a, na)
            @feed(b, nb)
            @feed(c[1], nc)
            @feed(d[1], nd)
    }
    exit()
}

probe end
{
    println("REM na=", na)
    println("REM @count(a)=", @count(a))
    println("REM nb=", nb)
    println("REM @variance(b)=", @variance(b))
    println("REM nc=", nc)
    println("REM @count(c[1])=", @count(c[1]))
    println("REM nd=", nd)
    println("REM @variance(d[1])=", @variance(d[1]))
    if ((na > nb) && (nc > nd))
        println("TEST_PASS")
    else
        println("TEST_FAIL")
}