ztcl::meter get
Gives the dict of the counts of a meter.
ztcl::meter get NAME
Description
Gives a dict with these keys:
name: the name of the meter;units: the compute units;wall_us,cpu_us: the wall time of each thread and child, and the CPU time of each thread, in microseconds, added up;mem_peak: the highest count of bytes of one thread or child;mem_avg,mem_byte_ms: the bytes in use on average overwall_us, and the bytes in use times the milliseconds;threads: a dict of the threads of each level,interpandprocess;io: a dict offile,socket, andpipe, each a dict of the bytes ofreadandwrite;connections: the sockets that a script opened;net: a dict of host words, each a dict ofread,write, andconnections; after 256 hosts the bytes go to the wordother;process: a dict for the threads of the levelprocess, ofmessages,bytes,start_us,os_cpu_us, andos_mem_peak;vm: a dict ofguests,run_us, andmem_byte_msfor the guests ofztcl::vm, each 0 in this version;budget,left: the budget and the units left in it, or empty strings.
The counts of a thread come in at its safe points, at the end of each script that thread::send runs in it, and at its end, so a read from another thread sees the counts of the last such point. A thread of the level process adds its counts at its end only. The wasm and WASI builds read no clock, so the counts of time are 0 there.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| NAME | string | required | The name of a meter. |
Returns
A dict.
Examples
Each example of this page runs after package require ztcl::json.
% ztcl::meter create demo
> dict keys [ztcl::meter get demo]
name units wall_us cpu_us mem_peak mem_avg mem_byte_ms threads io connections net process vm budget left
% ztcl::meter create demo
> set m [ztcl::meter get demo]
> list [dict get $m threads] [dict get $m io file]
{interp 0 process 0} {read 0 write 0}
% interp create k -meter g
> k eval {set a 1; set b 2}
> dict get [ztcl::meter get g] units
2
Errors
% ztcl::meter get nope
no meter "nope"
-errorcode ZTCL METER NAME
% ztcl::meter get
wrong # args: should be "ztcl::meter get name"
-errorcode TCL WRONGARGS
Facts
- Capability
meter. A new interpreter does not have it until the host turns it on.- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1