Open moorepants opened 10 years ago
More on the scale of what we are doing.
octave:13> profile on
octave:14> leg2d(rand(50000, 1), rand(50000, 12), rand(50000, 3), options);
Marker 1: 0 samples are missing, longest gap is 0 samples.
Marker 2: 0 samples are missing, longest gap is 0 samples.
Marker 3: 0 samples are missing, longest gap is 0 samples.
Marker 4: 0 samples are missing, longest gap is 0 samples.
Marker 5: 0 samples are missing, longest gap is 0 samples.
Marker 6: 0 samples are missing, longest gap is 0 samples.
octave:15> profile off
octave:16> T = profile('info');
octave:17> profshow(T)
# Function Attr Time (s) Calls
-------------------------------------------------------------
26 rtfilter 36.118 700000
25 myfiltfilt>rtfilter_batch 23.364 14
3 binary * 3.112 9438593
12 binary + 1.412 3146226
10 zeros 1.157 700906
24 binary / 1.061 3146179
29 pi 0.748 699154
5 size 0.745 701009
11 binary - 0.660 1748035
30 binary ^ 0.623 1747868
27 isempty 0.466 700000
28 binary <= 0.433 700018
31 sqrt 0.226 349577
7 binary != 0.050 35
33 lookup 0.040 18
2 leg2d 0.031 1
61 profile 0.022 1
32 interp1q 0.019 18
1 rand 0.017 3
15 diff 0.009 42
Octave 3.8 now has a JIT compiler that could speed up this filter loop. Another option would be to write the filter in C or something, as this is just a typical case where Matlab is poor: for loops. Finally, we could just change this out to a non-real time filter.
We should probably replace the call to myfilfilt with http://octave.sourceforge.net/signal/function/filtfilt.html and then use finite differences for the differentiation. It would speed things up considerably.
Here is the output from some real data:
octave:8> profshow (data);
# Function Attr Time (s) Calls
-------------------------------------------------------------
26 rtfilter 26.271 336056
25 myfiltfilt>rtfilter_batch 12.351 14
4 binary * 3.138 9073445
13 binary + 1.475 3024510
24 binary / 1.098 3024463
29 pi 0.762 672106
12 binary - 0.627 1680415
30 binary ^ 0.603 1680248
27 isempty 0.236 336056
31 sqrt 0.224 336053
28 binary <= 0.212 336073
3 leg2d 0.019 1
32 interp1q 0.008 18
11 zeros 0.008 66
43 atan2 0.004 4
16 diff 0.004 42
34 binary ./ 0.003 34
44 unwrap 0.003 4
33 lookup 0.003 18
20 flipud 0.002 21