I have a lot of legacy C code for image processing which needs to be as fast as possible. I have interfaced to it using C++ .NET and "extern C". Would it be worth trying to port it to C#? What are the performance tradeoffs?
Can image processing in C# be as fast as C++ by processing with unsafe code?
I think the performance will only degrade from porting the code. Image processing usually requires manipulation with memory blocks, pixel color component values etc. This can be easily done in C, but is too tricky for "safe" C#. Those "tricks" will require additional operations and definitely will eat a substantional share of performance.
Of couse, it is always possible to rewrite code "in C# way", but it will not be "porting" but "wrighting from scratch".
Reply:It's not going to be any faster in C#.
I have found that the Intel compiler does the best job of optimizing image processing code --- even better than hand-coded assembly.
Reply:write it in assembly for speed... otherwise absolutely port it. Well designed software will haul hiney on today's personal computers. If you are having lag problems in the render check to see if you can stream line your code ( i know obvious, but I had to say it ). Using "volitale" memory is only (relatively ) safe for "quick" application "popups". I wouldn't base any long term render on it. But go ahead and try it, maybe you'll design the next, smaller, faster render engine. Worse case is you'll learn why we don't use volitale mem.
Good luck
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment