hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_time_cpu (x05ba)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_time_cpu (x05ba) returns the amount of processor time used since an unspecified previous time.

Syntax

[result] = x05ba
[result] = nag_time_cpu

Description

nag_time_cpu (x05ba) returns the number of seconds of processor time used since some previous time. The previous time is system dependent, but may be, for example, the time the current job or the current program started running.
If the system clock of the host machine is inaccessible for any reason, nag_time_cpu (x05ba) returns the value zero.

References

None.

Parameters

Compulsory Input Parameters

None.

Optional Input Parameters

None.

Output Parameters

1:     result – double scalar
The result of the function.

Error Indicators and Warnings

None.

Accuracy

The accuracy of the value returned depends on the accuracy of the system clock on the host machine.

Further Comments

Since the value returned by nag_time_cpu (x05ba) is the amount of processor time since some unspecified earlier time, no significance should be placed on the value other than as a marker to be compared with some later figure returned by nag_time_cpu (x05ba). The amount of processor time that has elapsed between two calls of nag_time_cpu (x05ba) can be simply calculated as the earlier value subtracted from the later value.

Example

This example makes a call to nag_time_cpu (x05ba), performs some computations, makes another call to nag_time_cpu (x05ba), and gives the time used by the computations as the difference between the two returned values.
function x05ba_example


fprintf('x05ba example results\n\n');

[s1] = x05ba;

% compute appriximation to Euler's constant
nterms = 10^7;
h = 0;
for n = nterms:-1:1
  h = h + 1/n;
end
h = h-log(nterms+0.5);

[s2] = x05ba;

ctime = s2 - s1;

fprintf('It took %10.2e seconds\n', ctime);
fprintf(' to compute %8d terms of the harmonic series.\n', nterms);
fprintf('Approximation to Euler constant = %20.13f.\n', h);


x05ba example results

It took   1.02e-01 seconds
 to compute 10000000 terms of the harmonic series.
Approximation to Euler constant =      0.5772156649016.

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015