File: test_tic_toc.pro

package info (click to toggle)
gnudatalanguage 1.1.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 80,368 kB
  • sloc: cpp: 189,797; ansic: 46,721; sh: 677; python: 474; makefile: 146; xml: 69; f90: 28
file content (65 lines) | stat: -rw-r--r-- 2,001 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
;
; AC, 2016-03-03
;
; basic test to check whether TIC and TOC are working ...
; testing "label" and sum ...
;
pro TEST_TIC_TOC, nb_times=nb_times, no_exit=no_exit, $
                  help=help, test=test, verbose=verbose
;
if KEYWORD_SET(help) then begin
    print, 'pro TEST_TIC_TOC, nb_times=nb_times, no_exit=no_exit, $'
    print, '                  help=help, test=test, verbose=verbose'
    return
endif
;
fft_dim=1729
; **************IMPORTANT ***************
; make all procedures used in the loop below known, compiled and run before starting the test.
;
TIC & TOC & r = FFT(RANDOMU(seed, fft_dim, fft_dim)) ; this may take time the firsttime they are called.
; the variance test will not work if these are not already executed once.
; how many time we compute ...
if ~KEYWORD_SET(nb_times) then nb_times=4
val_times=DBLARR(nb_times)
;
cumul=TIC('cumul') ;; need to be just before loop
for i=0, nb_times-1 do begin
    ;; Start another clock named FFT
    ;; combined with the iteration number
    clock = TIC('FFT' + STRTRIM(i, 2))
    r = FFT(RANDOMU(seed, fft_dim, fft_dim))
    ;; For each iteration grab the end system time, 
    ;; then calculate and and print out the elapsed time 
    val_times[i]=TOC(clock)
    print, 'Time elapsed in loop '+STRING(i,'(i2)')+' : ', $
           val_times[i], ' seconds.'
endfor
;
; Grab the final system  for the entire loop
; and calculate and print the total elapsed time
;
val_cumul=TOC(cumul)
val_cumul=val_cumul[0]
;
print, 'Cumulative Time elapsed : ', TOTAL(val_times), ' seconds.'
print, 'Total Time elapsed      : ', val_cumul, ' seconds.'
;
errors=0
;
; We accepte a tolerance of 0.001 on the variance of measurements.
tolerance=0.001
;
m=moment(val_times)
precision=m[1]/m[0]
if (precision GT tolerance) then errors=1
print, 'Time Precision          : ', precision, '.'
;
BANNER_FOR_TESTSUITE, 'TEST_TIC_TOC', errors, short=short
;
if (errors GT 0) AND ~KEYWORD_SET(no_exit) then EXIT, status=1
;
if KEYWORD_SET(test) then STOP
;
end