Functions: Performance-Killers?

Started by
30 comments, last by Christoph 20 years ago
Hi, I noticed that in VB .NET, calling a function needs much time, too much for some real-time algorithms... However, as I can''t implement all the code directly, I need something like the "inline" parameter in C, which speeds up the function-call... Does anybody know a solution? Thanks and greetings
Advertisement
VB is a bad choice if you are so concerned about performance.
Note that I''m not trying to start a flamewar here
Why don''t you use c++ for your application?

-Nik

Niko Suni

quote:Original post by Nik02
VB is a bad choice if you are so concerned about performance.
Note that I''m not trying to start a flamewar here
Why don''t you use c++ for your application?


He said VB.NET, not VB6. Both C# and VB.NET compile to the same intermediate code, so they are just languages with a different syntax but the same results.
And I think the JIT compiler will inline functions whenever appropriate. Even if it doesn''t, calling a function isn''t that expensive, not even in .NET.
Because
1. VB is not too bad in the .net version - of course C++ is better
2. I''m not that good at C++
3. I''m currently working at a school work that is to be presented in october in front of a bunch of conservative anti-gamers (teachers ;-), therefore the code has to be clear and easy to understand...
A less radical solution might be to run the vb code through some kind of preprocessor (c''s, m4, etc) and implement the functions as macros.
Or you could rewrite the time critical parts in c as a dll or com object.
quote:Original post by Christoph
Because
1. VB is not too bad in the .net version - of course C++ is better
2. I''m not that good at C++
3. I''m currently working at a school work that is to be presented in october in front of a bunch of conservative anti-gamers (teachers ;-), therefore the code has to be clear and easy to understand...


1. VB is limited on many aspects
2. You should be able to learn C++, it would be a valuable experience... Plus you will have to switch someday, as VB is going to disappear.
3. I consider C++ code to be much clearer and much easier to understand than VB.


Looking for a serious game project?
www.xgameproject.com

Looking for a serious game project?
www.xgameproject.com
Are you sure that it is the calling of the functions that is too slow?
It seems infinitely more likely that the problem is with your algorithm or implementation than the function call itself.

-Extrarius
No, I''ve made time tests with simple math operations, its the call.
And I have already learned C++, but I''m not good enough to write a complex game... With my C, it''s just as with French - I can understand it, but being active... well ;-)
quote:Original post by Max_Payne
2. You should be able to learn C++, it would be a valuable experience... Plus you will have to switch someday, as VB is going to disappear.
3. I consider C++ code to be much clearer and much easier to understand than VB.



2. I bet C++''s usage will drop much faster than VB''s. C++ is a static, complex, binding language that puts too much on the shoulders of the programmers. I foresee a future with languages like Python, Smalltalk or Lisp features.

3. That''s just you. I think Lisp''s syntax is the cleanest (and most beautiful) of any language.
What types of tests have you run? Have you used a profiler (I hear decent things about DevPartner, which has a free 14-day trial).

This topic is closed to new replies.

Advertisement