Main Index : Reference :

time()


Description

Returns the time since the program was started.

Definition

[int] time()

Return Value

time() returns the number of milliseconds since CINEMA 4D was started.

Example

// Outputs "CINEMA 4D was started 1927752 seconds ago."
// (Yes, it *is* a stable program... :-)

println("CINEMA 4D was started ",time()/1000," seconds ago.");


// time() can be used to profile the speed of an algorithm.
//
// Outputs "Each loop took 0.00012 seconds.".

var i,starttime,endtime,num;

num = 2000.0;
starttime = time();

for (i=0;i<num;i++) 
{
  // Do some stuff
}

endtime = time();

println("Each loop took ",(endtime-starttime)/num/1000.0," seconds.");


// time() can also be used as seed for the random number
// generator, when total randomness is wanted.

var random = new(Random);
random->Init(time());

See Also

Random