Performance impact: C# vs C++ classes

  • Thread starter Thread starter Chuck Bowling
  • Start date Start date
C

Chuck Bowling

I have a library if C functions that will eventually get wrapped in a class.
The question is, should i wrap them in a C++ wrapper and call the wrapper
from C# or should I wrap the C functions in a C# wrapper? Anybody got any
insight on this? My primary goal is speed. This is an audio application that
can get pretty cpu intensive depending on how the user has it configured...
 
If you just need to make the C functions accesible from .NET, I'd
suggest creating a C# wrapper that PInvokes the functions. If
performance is critical you'll want to make very coarse grained
functions. The overhead of switching from manged code to unmanaged
code can be high - not something you'd want to do inside a tight loop
in perf critical situation.
 
Bart, I took a look at SWIG and it looks very interesting. I'll have to look
closer before I can decide if it'll be useful for what I'm doing, but in
either case it looks good. Thanks for the link.
 
Thanks for the reply Scott. I'm aware that most of the overhead is in
switching from unmanaged to managed. Mainly I was interested in finding out
if there might be any performance gain in switching to managed in C++
classes as opposed to PInvoke and C#.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top