-
Notifications
You must be signed in to change notification settings - Fork 8
/
bench.sas
21 lines (19 loc) · 882 Bytes
/
bench.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
%macro bench
/*----------------------------------------------------------------------
Measures elapsed time (in seconds) between sucessive invocations
----------------------------------------------------------------------*/
(mvar /* Macro variable used for recording start time (default=_bench)*/
);
/*----------------------------------------------------------------------
Call it once to start the timing and then a second time to report the
elapsed time and clear the saved time.
Use different values for MVAR to time multiple overlapping periods.
----------------------------------------------------------------------*/
%if (&mvar=) %then %let mvar=_bench;
%if ^%symexist(&mvar) %then %global &mvar;
%if (&&&mvar =) %then %let &mvar = %sysfunc(datetime());
%else %do;
%put NOTE: Elapsed seconds = %sysevalf(%sysfunc(datetime()) - &&&mvar);
%let &mvar =;
%end;
%mend bench;