views:

132

answers:

3

Hi All, I would like to build my own signal processing library, and possibly another one about graphs algorithm. I find C# very useful and robust in regards of possible bugs associated with memory allocation, pointers, threading etc...

But I was wondering how much am I going to lose in terms of performance. Is it going to be something acceptable?

Thanks

+4  A: 

With the right hardware, you shouldn't have an issue.

Something to think about though: I have no trouble whatsoever trying to find a library to do signal processing in C++. However, I can't easily find much information at all dealing with signal processing for C#.

If you can find a way to make it work, you might have just found a way to get into a niche area of development that many other people can benefit from.

Just something to think about. Unless you are doing this on some mission critical system it probably doesn't matter either way. I'd just go with whatever you think will benefit you more in the long term.

Robert Greiner
+1. good answer
Aliostad
+1 for considering the "C#-niche" aspect.
Novox
+5  A: 

When I started my DSIP course I was a pure C# developer . After looking around for a while, I ended up using C++libraries and learning C++ which at end it was to my benefit since I was doing real-time image processing and there is no way C# can match the performance.

In fact, you can run a quick test and run a mathematical equation consisting of a few multiplication in C# and C++ a million times and see the huge difference that there is doing calculations with floating point numbers.

If you are lucky, you will get wrappers in C# which is the best of both worlds, fast calculation in C++ and easy to use in C#. There is a C# wrapper for OpenCV and it seems to be quite good (http://www.emgu.com/wiki/index.php/Main_Page).

I highly recommend OpenCV especially for 2D signal processing. It is great in performance and made my project possible. Have a look at the demo here: http://www.youtube.com/watch?v=NeQvcdRPxoI and http://www.youtube.com/watch?v=NqYPJELHkhA

Aliostad
+1 nice thinking on the wrappers... It's been so long since I've used one that I tend to forget they exist.
Robert Greiner
is there any "de facto" standard for signal processing in C++?
Banana
+1  A: 

It's not so much about the performance loss in C# but the unpredictability of when garbage collection is performed. During GC all managed threads are frozen until the GC is completed. During that time you cannot do any processing, which for 99% of applications won't matter, but for signal processing is critical. This is i.e. why you don't see a Microsoft sanctioned managed version of DirectShow or other "real time" signal processing applications.

BrokenGlass
Similar to a Garbage Collector, you cannot predict when malloc or new will walk the free chain and consolidate memory either. You can control when the GC runs if you absolutely need to.
Ankur Goel
GC normally takes only 20-30ms. So it should not be a problem.
Aliostad
Ankur: That's one of the reasons why you would use a memory arena /preallocate instead of using regular malloc, so that one doesn't count in my mind.
BrokenGlass