1if not modules then modules = { } end modules ['node-snp'] = {
2 version = 1.001,
3 comment = "companion to node-ini.mkiv",
4 author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5 copyright = "PRAGMA ADE / ConTeXt Development Team",
6 license = "see context related readme files"
7}
8
9if not nodes then
10 nodes = { }
11end
12
13local snapshots = { }
14nodes.snapshots = snapshots
15
16local status = status
17
18local nodeusage = nodes.pool and nodes.pool.usage
19local nodestock = nodes.pool and nodes.pool.stock
20local clock = os.gettimeofday or os.clock
21local lasttime = clock()
22local samples = { }
23
24function snapshots.takesample(comment)
25 if nodeusage then
26 local c = clock()
27 samples[#samples+1] = {
28 nodes = nodeusage(),
29 stock = nodestock(),
30 texcallbacks = status.getcallbackstate(),
31 mpcallbacks = mplib.getcallbackstate(),
32 backendcallbacks = backends.getcallbackstate(),
33 luavariables = status.getluastate(),
34 texvariables = status.gettexstate(),
35 comment = comment,
36 variables = {
37 lasttime = c,
38 elapsed = c - lasttime,
39 },
40 memories = {
41 pool = status.getpoolstate(),
42 hash = status.gethashstate(),
43 lookup = status.getlookupstate(),
44 node = status.getnodestate(),
45 token = status.gettokenstate(),
46 buffer = status.getbufferstate(),
47 input = status.getinputstate(),
48 file = status.getfilestate(),
49 nest = status.getneststate(),
50 parameter = status.getparameterstate(),
51 save = status.getsavestate(),
52 expand = status.getexpandstate(),
53 read = status.getreadstate(),
54 font = status.getfontstate(),
55 language = status.getlanguagestate(),
56 mark = status.getmarkstate(),
57 sparse = status.getsparsestate(),
58 insert = status.getinsertstate(),
59 mvl = status.getmvlstate(),
60 },
61 }
62 end
63end
64
65function snapshots.getsamples()
66 return samples
67end
68
69function snapshots.resetsamples()
70 samples = { }
71end
72 |