cputic

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 4.0, Creation date: 2017-08-01, Last change: 2025-08-18

similar to tic but uses the cpu timer



See Also: cputoc

Example Illustration

 missing image of cputic

Syntax

cputic

Examples


tic; for i=10000000000; x=cos(pi/16); end; toc
cputic; for i=10000000000; x=cos(pi/16); end; cputoc
f=@() cos(pi/3), timeit(f)




Copyright 2017-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This function, cputic, is a simple utility designed to start a CPU time measurement. It is part of the SolidGeometry library and was introduced in version 4.0. The function is authored by Tim C. Lueth and is categorized under auxiliary procedures.

Input Parameters

The function cputic does not take any input parameters. It is called without arguments.

Global Variables

The function uses a global variable ctic_tic to store the current CPU time when the function is called. This variable is used to keep track of the start time for a CPU time measurement.

Function Workflow

  1. The function declares a global variable ctic_tic.
  2. It assigns the current CPU time, obtained from the cputime function, to the global variable ctic_tic.

Usage

The function is used to mark the start of a CPU time measurement. It is typically used in conjunction with the cputoc function, which calculates the elapsed CPU time since cputic was called.

Example

Here is an example of how cputic can be used:

tic; for i=10000000000; x=cos(pi/16); end; toc
cputic; for i=10000000000; x=cos(pi/16); end; cputoc
f=@() cos(pi/3), timeit(f)

In this example, cputic is used to start the CPU time measurement before a loop, and cputoc is used to end the measurement and display the elapsed CPU time.

Algorithm explaination created using ChatGPT on 2025-08-18 21:53. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21