Performance penalties of interop'ing C# with C functions [closed] - c#

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Barring actual performance tests of my code (I'm at the design stage), what is the general consensus on interfacing C code into C#? When will it be fruitful to do so, and when would it not?

There is no simple answer.
Most of the time, the overhead of marshaling parameters into and back from methods will be negligible, and often far lower then the processing done inside the function if it's not a trivial function. However, doing it inside a tight, performance-critical loop might violate your performance constraints.
The overhead itself largely depends on type of arguments and return values of the method. It is cheaper to marshal an integer than an array containing structures which contain many strings.
It is impossible to tell without knowing your use cases.

Related

Why are ValueTypes in Object Oriented Languages like C# ,Java [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
Hi I just want to know for knowledge why there are Value Types in C# or Java . Why they all are not Reference Types?. I can see two reasons for my own:
1)Performance: All commonly used DataTypes are Value types since Value Types have single round where as Reference Types have two rounds first to stack and then to heap.So performance can be the reason. 2)Assigning Values.Any help will be highly appericiated.Thanks
Part of it is performance but a bigger reason is the resulting behavior. You tend to think of integers (for example) as immutable value types. However, if you're dealing with an object, you would be surprised if updating a field in that object wasn't maintained in a calling method because you were modifying a copy.

Is There Any Way To Make A Self JIT Compiled Program? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Instead of needing something like Java, is there a way I could make a program that has a small piece of machine code to compile itself?
It is theoretically possible. But in practice, it would be a lot of work, and the result would not be a small program. In fact, it would be roughly equivalent in size and functionality / complexity to a standard JVM. Which leads to the obvious point that it is unlikely to be worth the effort.
I suggest that you just use a standard JVM, and leverage the (probably) hundreds of man-years of effort that the implementors have put into building high quality JIT compilers ...

CircularBuffer highly efficient implementation (both thread-safe and not thread-safe) [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Could someone suggest good CircularBuffer implementation? I need both "not thread-safe" and "thread-safe" versions. I expect following operations:
ability to provide size of the buffer when creating
adding elements
iterating elements
removing elements while iterating
probably removing elements
I expect implementation to be highly optimized in terms of speed and used memory, average and worst times etc.
I expect "not thread-safe" implementation to be extremely fast. I expect "thread-safe" implementation to be fast, probably using "lock-free code" for synchronization and it's ok to have some restrictions if this is required for speed.
If buffer is too small to store new (added) element it's ok to silenty override existent element or raise exception.
Should I use disruptor.net?
Adding link to a good example Disruptor.NET example
Not thread safe:
System.Collections.Generic.Queue
Thread safe:
System.Collections.Concurrent.ConcurrentQueue
or
System.Collections.Concurrent.BlockingCollection (which uses a concurrent queue by default internally)
Although technically you really shouldn't use the term "thread safe". It's simply too ambiguous. The first is not designed to be used concurrently by multiple threads, the rest are.

Clone and equal method in Eiffel [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Why define a clone or equal method in Eiffel gives greater protection with respect to types problems in comparison to something similar in C#?
clone and equal don't offer anything great actually. These 2 routines are on their way out, replaced respectively by twin and the operator ~ in the latest estudio versions.
The problem with both of these routines was that don't offer great protection. The both take objects of type ANY (which is a problem). Their new counterparts are much safer and provide better control at compile time.

Which language would be more suitable than the other for manipulating huge graphs, F# or C#? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Are their advantages to either C# or F# that would make that language more suitable for manipulating huge graphs?
Neither.
Both C# and F# are excellent languages that poses the capabilities to examine large data structures in an efficient manner. Virtually any solution coded up in one language could be coded up in the other. True there would be some syntactic differences and the occasional language construct which doesn't port cleanly between the two. But neither language has an inherent advantage in this area.
Instead of focusing on the language here I would focus on the algorithm. That much more than the language will determine the efficiency of your program.
Both of these will compile to the same set of MSIL instructions. There may be some semantic difference at the IL level between the cleanest F# algorithm and the cleanest C# algorithm, but it wouldn't be significant.
As JaredPar said, both are equally capable of efficiently traversing large data graphs.

Categories