File size: 3,344 Bytes
cac0868
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""sampler_census.py — fall-time measured entirely on the instrument surface.

The reading-stamp method is tautological: the nvidia-smi query IS a full ask, so every
reading lands 0 low-util samples after its own wake. This organ drops readings entirely.

Definitions (printed with units):
- EPISODE = maximal run of consecutive samples with power < SUB_W AND sm util < 10 (a resting landing).
- FALL-TIME of an episode = cumulative low-util samples (util<10) in the window from the last
  high-util sample (util>=50) before the episode, to the episode start. Unit: minutes = samples/60.
- Gear of episode = SM clock at first episode sample (pass 185: a record names its gear).

Prints: episode table, fall-time distribution by landing class, gear histogram.
"""
import time

U = r"C:/Users/user/1f916-contribution"
SUB_W = 214.0   # woken-idle floor (P-BODY-2 surface)
IN_W = 241.69   # top of hot-gear idle range (P-BODY-3 surface)

def load():
    rows = []
    for l in open(U + r"\gpu-history.csv"):
        p = l.split()
        if len(p) < 14 or p[0].startswith("#"):
            continue
        try:
            ts = time.mktime(time.strptime(p[0] + " " + p[1], "%Y%m%d %H:%M:%S"))
            w = int(p[3]); sm = int(p[6]); pclk = int(p[13])
        except ValueError:
            continue
        rows.append((ts, w, sm, pclk))
    rows.sort()
    return rows

def run():
    rows = load()
    if not rows:
        print("no sampler rows"); return
    t0, t1 = rows[0][0], rows[-1][0]
    print(f"sampler window: {round((t1-t0)/60,2)} min, {len(rows)} samples")

    # find episodes: consecutive runs where w < SUB_W and sm < 10
    eps = []
    i = 0
    n = len(rows)
    while i < n:
        ts, w, sm, clk = rows[i]
        if w < SUB_W and sm < 10:
            j = i
            while j < n and rows[j][1] < SUB_W and rows[j][2] < 10:
                j += 1
            eps.append((i, j))   # [i, j)
            i = j
        else:
            i += 1
    print("sub-floor resting episodes:", len(eps))

    table = []
    for (a, b) in eps:
        start = rows[a][0]
        # last high-util sample strictly before episode
        ask = None
        for k in range(a-1, -1, -1):
            if rows[k][2] >= 50:
                ask = rows[k][0]; break
        seg_start = ask if ask is not None else t0
        low = sum(1 for k in range(a) if seg_start <= rows[k][0] < start and rows[k][2] < 10)
        ft = round(low/60, 2)
        dur = round((rows[b-1][0]-start)/60, 2)
        wmin = min(rows[k][1] for k in range(a, b))
        gear = rows[a][3]
        table.append((time.strftime("%H:%M:%S", time.gmtime(start)), ft, dur, wmin, gear))

    print("episode | start(UTC) | fall-time(min) | duration(min) | minW | gear(MHz)")
    for e in table[:40]:
        print(f"  {e[0]}  ft={e[1]}  dur={e[2]}  minW={e[3]}  gear={e[4]}")

    fts = sorted(e[1] for e in table)
    if fts:
        med = fts[len(fts)//2]
        print(f"fall-time distribution (unit: minutes): n={len(fts)} min={min(fts)} median={med} max={max(fts)}")
        ge20 = sum(1 for x in fts if x >= 20)
        print(f"episodes with fall-time >= 20 min: {ge20} of {len(fts)}")
    from collections import Counter
    print("gear histogram (episode start clock):", dict(sorted(Counter(e[4] for e in table).items())))

if __name__ == "__main__":
    run()