# 22. Virtuoso Functions Guide - msec_time

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
Virtuoso Functions Guide
Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
datestring, ...
curdate
dateadd
datediff
datestring_gmt
dayname
dayofmonth
dayofweek
dayofyear
dt_set_tz
get_timestamp
getdate
hour
minute
month
monthname
msec_time
now
quarter
second
stringdate
stringtime
timezone
week
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
Remote SQL Data Source
Replication
SOAP
SQL
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web Server & Internet
XML
XPATH & XQUERY
Functions Index

## msec_time

Get number of milliseconds from system epoch
msec_time
Parameters
No parameters – The function does not take parameters.
Return Values

A 32-bit integer no. of milliseconds since system epoch.

Description

msec_time returns the number of milliseconds since system epoch. It is useful for benchmarking purposes, timing operations, etc.

Examples
Simple example

Time a function

    create procedure
    fib (in n integer)
    {
      if (n <= 2) return 1;
      return fib (n - 1) + fib (n - 2);
    }
    ;

    create procedure
    time_fib (in n integer)
    {
      declare t,i integer;
      declare msg varchar;

      result_names (msg);

      t := msec_time();
      i := fib (n);
      result (sprintf ('fib (%d) is %d, got it in %d milliseconds.',
    	           n, i, msec_time() - t));
    }
    ;

    SQL> time_fib(10);
    msg
    VARCHAR NOT NULL
    _______________________________________________________________________________

    fib (10) is 55, got it in 10 milliseconds.

    1 Rows. -- 21 msec.

See Also

now