The trivial-time Reference Manual

This is the trivial-time Reference Manual, version 0.0.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Fri May 15 13:09:06 2026 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 trivial-time

trivial-time allows timing a benchmarking a piece of code portably

Author

Artyom Bologov

Home Page

https://codeberg.org/aartaka/trivial-time

Source Control

(GIT https://codeberg.org/aartaka/trivial-time.git)

Bug Tracker

https://codeberg.org/aartaka/trivial-time/issues

License

BSD-2 Clause

Version

0.0.0

Source

trivial-time.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 trivial-time/trivial-time.asd

Source

trivial-time.asd.

Parent Component

trivial-time (system).

ASDF Systems

trivial-time.


3.1.2 trivial-time/package.lisp

Source

trivial-time.asd.

Parent Component

trivial-time (system).

Packages

trivial-time.


3.1.3 trivial-time/trivial-time.lisp

Dependency

package.lisp (file).

Source

trivial-time.asd.

Parent Component

trivial-time (system).

Public Interface
Internals

4 Packages

Packages are listed by definition order.


4.1 trivial-time

‘trivial-time’ provides two macros for code timing/benchmarking: - ‘time’ counts the time, GC stats, and error rate of the code. - ‘benchmark’ runs the code X times and prints the aggregate stats.

There’s also ‘with-time’ as the underlying implementation between these, available for use outside them.

Source

package.lisp.

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Macros

Macro: benchmark ((&optional repeat) &body forms)

Run FORMS REPEAT times, recording ‘time’-ing data per every run. Print the total and average statistics across the runs.
Return the values returned by the last evaluation of FORMS.

REPEAT defaults to 1000.

Affected by:
- ‘with-time’ implementation support.
- ‘*trace-output*’ for printing.
- Print variables for float format and form printing.

Bear in mind: some implementations take considerable time for these measurements, so the run time might add up to more than the actual code run time. Use caution.

Package

trivial-time.

Source

trivial-time.lisp.

Macro: time (&rest forms)

Execute FORMS and print timing information for them. The values of last form in FORMS are returned unaltered.

Affected by:
- ‘with-time’ implementation support.
- ‘*trace-output*’ for printing.
- Printer variables for float format and form printing.

Package

trivial-time.

Source

trivial-time.lisp.

Macro: with-time ((&rest time-keywords) (&rest multiple-value-args) form &body body)

Measure the timing properties for FORM and bind them to TIME-KEYWORDS in BODY. The values of FORM are bound to MULTIPLE-VALUE-ARGS.

Both TIME-KEYWORDS and MULTIPLE-VALUE-ARGS are destructuring lists, allowing for &REST, &KEY etc. in them.

TIME-KEYWORDS is a &KEY destructuring list, but one may omit &KEY and &ALLOW-OTHER-KEYS in it.

TIME-KEYWORDS are destructuring a keyword-indexed property list with:
- :REAL — for real time (in seconds, float).
- :USER — for user-space CPU use/run time (in seconds, float).
- :SYSTEM — for system-space CPU use/run time (in seconds, float).
- :CYCLES — for CPU cycles spent.
- :GC-COUNT — for the times GC was invoked.
- :GC — for time spend on GC (in seconds, float).
- :ALLOCATED — for the amount of bytes consed.
- :ABORTED — for whether the evaluation errored out.
- :FAULTS — for the number of page faults (both major and minor).

Not all of properties are guaranteed to be there. More so: it’s almost always the case that some are missing.

Example of use:

(with-time (real user gc allocated)
()
(apropos "")
(format t "~&Real ~f~
~&User ~f~
~&GC ~f~
~&Allocated ~a" real user gc allocated))

Package

trivial-time.

Source

trivial-time.lisp.


5.2 Internals


5.2.1 Generic functions

Generic Function: %benchmark (repeat thunk form)
Package

trivial-time.

Source

trivial-time.lisp.

Methods
Method: %benchmark ((repeat integer) (thunk function) form)
Generic Function: %time (thunk form)
Package

trivial-time.

Source

trivial-time.lisp.

Methods
Method: %time ((thunk function) form)

Appendix A Indexes


A.1 Concepts


A.3 Variables