utc.benchmark ( )

Function stats

Average user rating
37
373
9999
Support
FileMaker 10.0 +
Date posted
03 December 2014
Version
1
Recursive function
No

Author Info
 Fabrice

74 functions

Average Rating 4.4

author_avatar



 

Function overview

Prototype

utc.benchmark  ( _var.init;   _var.compare )


Parameters

_var.init  string, optional


_var.compare  string, optional


Description

Tags:  Dev   Debug  

debug function to benchmark scripts and calculations

v1    Dec 2014

In the following description, 'in seconds' means: milliseconds / 1000

Parameters: /!\Be careful, the naming must be compatible with variable naming (no punctuation, blanks...)
    _var.init    string, optional. If defined, declares a variable named after this parameter ($$utc.<_var.init>).
    _var.compare    string, optional. If defined the function returns the difference in seconds between current and $$utc.var.compare. If empty, the function returns current timestamp.


Purpose:
    easily measure performance between two calls.
    Example:
        Let ([
         x = utc.benchmark ( "start" ; "" ) ;
         eval = Get ( DocumentsPathListing )
        ];
         utc.benchmark ( "end" ; "start" )
        )
    returns the time required by Get ( DocumentsPathListing ) to evaluate.

    in scripts, you can also:

    Set variable [ $void ; utc.benchmark ( "start" ; "" )
    Do stuff
    Set variable [ $void ; utc.benchmark ( "beforeSubscript" ; "start" ) // $void is now set to the duration of 'do stuff' ]
    Perform subscript [ a somehow long script ]
    Set variable [ $void ; utc.benchmark ( "" , "beforeSubscript" ) // $void is now set to the duation of the subscript ]
    ...
    ...

Examples

Sample input

utc.benchmark ( "end" ; "start" )


Sample output

1.355

 

Function code

/*
utc.benchmark ( _var.init ; _var.compare )

by Fabrice Nordmann, 1-more-thing
@1morethingtweet

debug function to benchmark scripts and calculations

v1    Dec 2014

In the following description, 'in seconds' means: milliseconds / 1000

Parameters: /!\Be careful, the naming must be compatible with variable naming (no punctuation, blanks...)
    _var.init    string, optional. If defined, declares a variable named after this parameter ($$utc.<_var.init>).
    _var.compare    string, optional. If defined the function returns the difference in seconds between current and $$utc.var.compare. If empty, the function returns current timestamp.


Purpose:
    easily measure performance between two calls.
    Example:
        Let ([
         x = utc.benchmark ( "start" ; "" ) ;
         eval = Get ( DocumentsPathListing )
        ];
         utc.benchmark ( "end" ; "start" )
        )
    returns the time required by Get ( DocumentsPathListing ) to evaluate.

    in scripts, you can also:

    Set variable [ $void ; utc.benchmark ( "start" ; "" )
    Do stuff
    Set variable [ $void ; utc.benchmark ( "beforeSubscript" ; "start" ) // $void is now set to the duration of 'do stuff' ]
    Perform subscript [ a somehow long script ]
    Set variable [ $void ; utc.benchmark ( "" , "beforeSubscript" ) // $void is now set to the duation of the subscript ]
    ...
    ...

*/



Let ([
    _now = Get ( CurrentTimeUTCMilliseconds ) ;
    _compare = Case ( not IsEmpty ( _var.compare ) ; GetAsNumber ( Evaluate ( "$$utc." & _var.compare ))) ;
    _init = Case ( not IsEmpty ( _var.init ) ; Evaluate ( "let($$utc." & _var.init & "=" & _now & ";\"\" )" ))
];
    Case ( not IsEmpty ( _var.compare ) ; _now - _compare ; _now ) / 1000
)

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/373

    Prototype: utc.benchmark( _var.init; _var.compare )
    Function Author: Fabrice (http://www.fmfunctions.com/mid/37)
    Last updated: 03 December 2014
    Version: 1

*/
// ===================================

 

 

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (31)
Date  (28)
XML  (26)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (12)
Layout Objects  (11)
Filter  (11)
Design  (10)
Array  (7)