ztcl::meter
ztcl::meter subcommand ?arg ...?
Counts the compute units, the time, the memory, and the I/O of threads and child interpreters, for a host that bills its customers. A compute unit is the same on each machine and with the JIT on or off. A record is a line of JSON in a hash chain, with an optional Ed25519 signature.
Subcommands
| Synopsis | What it does |
|---|---|
ztcl::meter create NAME ?-budget UNITS? ?-tenant TEXT? |
Makes the meter NAME, or sets the options of the meter NAME. A budget caps the compute units of all the threads of the meter. |
ztcl::meter get NAME |
The dict of the counts of NAME. |
ztcl::meter list |
The names of the meters. |
ztcl::meter reset NAME |
Sets each count of NAME to zero. |
ztcl::meter delete NAME |
Removes NAME. A thread that counts in it goes on to count in it until it ends. |
ztcl::meter run NAME SCRIPT |
Runs SCRIPT in the current interpreter and counts it in NAME. The budget of NAME caps the units of SCRIPT. |
ztcl::meter record NAME ?-tenant TEXT? ?-script TEXT? ?-sign? ?-key SEED? |
The usage record of NAME: one line of JSON with the SHA-256 of the record before it. -key signs with the Ed25519 key of a 64-digit hex seed, and -sign with the key of the host. |
ztcl::meter verify RECORD PUBLICKEY |
1 when the signature of RECORD matches the hex public key, else 0. |
ztcl::meter pubkey SEED |
The hex public key of a hex seed. |
Examples
ztcl::meter create demo -tenant acmegivesdemoztcl::meter run demo {set a 1; set b 2}; dict get [ztcl::meter get demo] unitsgives2ztcl::meter create small -budget 100givessmallcatch {ztcl::meter run small {while 1 {}}} msg; set msggivescompute limit reached
Errors
ztcl::meter get nopegives the errorno meter "nope"
Facts
- Capability:
meter. A new interpreter does not have this command. See Limits and capabilities. - Compute cost: one compute unit for the call, and more for the commands that it runs.
- The full page: ztcl::meter.