0

I am developing a program in c#, and thanks to the matlab .net builder, I am using a matlab mapping toolbox function "polybool", which in one of it's options calculate the difference of 2 polygons in 2-D. The problem is that the functions takes about 0.01 seconds to finish in which is bad for me because I call it a lot. And this doesn't make sense at all because the polygons are 5 points each, so there is no way that it take 0.01 second to find the results. Does anyone has any ideas?

2
  • "tic; code; toc" is your friend Commented Mar 7, 2010 at 18:46
  • Measuring timing can be a bit tricky, especially when the function does not take a lot of time to evaluate. I suggest you use timeit (mathworks.com/matlabcentral/fileexchange/18798) instead of tic/toc to check. Commented Mar 7, 2010 at 19:08

1 Answer 1

1

How are you computing the 0.01 seconds? If this is total operational time, it may very well be the marshaling in and out of the toolbox functionality, which will take some time. The actual routine may be running quickly, but getting your data from C# into the routine, and the results back, will have some overhead involved with the process.

Granted, this overhead probably scales well - since it's most likely (mostly) constant, so if you start dealing with larger polygons, you'll probably see your overall efficiencies scale very well.

Sign up to request clarification or add additional context in comments.

1 Comment

Right, but large numbers of polygons might not. If polybool executes fast when called from Matlab and slow when called from C#, I'd start looking for a C# or C++ implementation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.