sample

gather information for execution profiling (WATCOM)

Syntax:

sample [options] [command_name [argument...] ]

Options:

-b numbufs
Use this number of buffers (default is 2). A buffer holds up to 2000 samples.
-d
Discard all samples that sample collects while it's writing a buffer.
-f file
Save data to this file (default is command_name.smp in the current directory).
-k
Keep samples from all processes in the system. By default, sample keeps samples only from the specified process or command.
-L file
Use the shared executables specified in this file.
-l pid
Use this shared library, where pid is the process ID of the library.
-p pid
Sample this process (default is the specified command).
-q
Be quiet; don't print information messages.
-s seconds
Save this many seconds worth of samples.
-w
Wait for all buffers to fill before writing to file.

Examples:

Sample process pid 234 until it terminates or Ctrl-C is pressed:

sample -p 234

Run and sample busy until it terminates, Ctrl-C is pressed, or 10 seconds of samples have been gathered:

sample -s 10 busy

Sample process pid 3 until it terminates, Ctrl-C is pressed, or 60 seconds of samples have been gathered; discard samples that occur while writing data to disk:

sample -p 3 -s 60 -d

Description:

The Sampler takes snapshots of an executing program. It interrupts the program at regular intervals and records which region of the program was being executed at each interrupt.

Since regions that consume large amounts of time have a greater chance of being sampled, the information that the Sampler records provides a statistical measure of how much various regions contribute to execution time. The Sampler saves this information in a sample file. This information can then be analized with the Profiler command, wprof.

See also:

wprof, the Execution Profiler chapter in the Compiler & Tools User's Guide