From: Bruno Luong on 4 May 2010 06:57 "Michael " <michael.schmittNOSPAM(a)bv.tum.de> wrote in message <hrosth$5r7$1(a)fred.mathworks.com>... > Simple answer: I have tested this procedure on some small dataset (100 x 100 pixels) and had a speed gain of about 25%. Although I need to test the reliability of the CMEX implementation... I have doubt if you do the correct timing (which is not trivial to get it right as it seems to be, believe me). To be certain I have tried my own test of calling a function directly from Matlab and from mex. The timing speak for itself, the overhead of mexEvalString is HUGE. function bar tic for n=1:10000; r = foo; end toc % 0.005447 seconds clear r tic for n=1:10000; callfoo; end % Elapsed time is 0.845930 seconds. toc end % bar function r = foo r = 1.0; end % foo // callfoo.c #include <string.h> #include "mex.h" void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { char text[200]; strcpy(text, "r = foo;"); mexEvalString(text); return; } // callfoo.c Bruno
From: Michael on 4 May 2010 07:51 You may be right - I don't really know whether it's really worthwhile. That's why I wanted to give it a try. Nevertheless you should be careful with your comparison: I do the for-loop within C/MEX! With for-loops being terrifyingly slow in MATLAB, I would believe you would have better timing using the following test: #include <string.h> #include "mex.h" void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { char text[200]; int i; for(i = 0; i<=10000;i++) { strcpy(text, "r = foo;"); mexEvalString(text); } return; } // callfoo.c Nevertheless this wasn't my original problem. ;) Any help on the segmentation violation would be appreciated.
From: Bruno Luong on 4 May 2010 08:00 > > Nevertheless this wasn't my original problem. ;) Any help on the segmentation violation would be appreciated. Have you seen my comments on FREE? Those are very wrong. Bruno
From: Bruno Luong on 4 May 2010 08:17 "Michael " <michael.schmittNOSPAM(a)bv.tum.de> wrote in message <hrp1n9$er5$1(a)fred.mathworks.com>... > I would believe you would have better timing using the following test: Why don't you do it yourself? Bruno
From: Michael on 4 May 2010 09:05 "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hrp382$o7c$1(a)fred.mathworks.com>... > "Michael " <michael.schmittNOSPAM(a)bv.tum.de> wrote in message <hrp1n9$er5$1(a)fred.mathworks.com>... > > I would believe you would have better timing using the following test: > > Why don't you do it yourself? > > Bruno Because I already did a tic-toc test and experienced a speed gain of 25% (cf. my previous messages). With my last message I only replied to your (not sufficient) argumentation.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: problem with symbolic integration Next: How can I compare 2 surfaces?? |