pdist2 - bottleneck is in argument parsing
조회 수: 2 (최근 30일)
이전 댓글 표시
I'm profiling some code to see where the bottlenecks are, and I saw the bottleneck was in pdist2--expected.
What was unexpected is that the profiler is showing that there are two hot spots: 17% in pdist2mex and 37% in internal.stats.parseArgs(!). It's spending twice as much time parsing arguments as calculating distances.
How can I eliminate this overhead?
댓글 수: 1
dpb
2018년 7월 11일
For a specific case you could probably decipher the arguments and call pdist2mex directly if your data are suitably arranged.
I've not looked at the details recently so don't recall just what is done up front otomh.
답변 (1개)
OCDER
2018년 7월 11일
To bypass the overhead, you could make your own MEX file for pdist2. Or, use pdist2mex directly, but then you'll have to find this mex file and pull it out of the private folder into your own folder in the matlab path.
EXAMPLE
X = randn(100, 5);
Y = randn(25, 5);
dist = 'euc';
additionalArg = [];
smallestLargestFlag = [];
radius = [];
D = pdist2mex(X',Y',dist,additionalArg,smallestLargestFlag,radius); %Same as pdist2(X, Y, dist)
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!