-
Notifications
You must be signed in to change notification settings - Fork 0
/
mini.js
48 lines (48 loc) · 1.24 KB
/
mini.js
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
just.sys = just.load('sys').sys
const mem = new BigUint64Array(16)
just.memoryUsage(mem)
const rss = mem[0]
const AD = '\u001b[0m'
const AG = '\u001b[32m'
function dump (o, name) {
const fields = Object.getOwnPropertyNames(o).sort()
just.print(`${AG}${name}${AD}\n${JSON.stringify(fields, null, ' ')}`)
for (const field of fields) {
if ((typeof o[field]) === 'object') dump(o[field], `${name}.${field}`)
}
}
just.print(JSON.stringify(just.args))
just.print(JSON.stringify(just.version))
just.print(just.builtin('mini.js'))
dump(just, 'just')
function loadLibrary (name, path = `${name}.so`) {
return just.load(just.sys.dlsym(just.sys.dlopen(path), `_register_${name}`))
}
just.memoryUsage(mem)
just.print(`rss ${mem[0]} used ${mem[0] - rss}`)
function dumplib (name, path) {
dump(loadLibrary(name, path), name)
}
dumplib('blake3')
dumplib('encode')
dumplib('epoll')
dumplib('ffi')
dumplib('fs')
dumplib('html')
dumplib('http')
dumplib('inspector')
dumplib('netlink')
dumplib('net')
dumplib('pg')
dumplib('sha1')
dumplib('signal')
dumplib('sys')
dumplib('tcc')
dumplib('thread')
dumplib('udp')
dumplib('vm')
dumplib('zlib')
dumplib('crypto', 'openssl.so')
dumplib('tls', 'openssl.so')
just.memoryUsage(mem)
just.print(`rss ${mem[0]} used ${mem[0] - rss}`)