G
Guest
I do a project using C# and C++ .NET and have some functionality to convert
imperial to metric units and vice versa.
In VC6 I just used a simple header file with some constants (e.g. const
double MM_TO_INCH = 1.0/25.4.
For .NET I thought it might be a good idea to have a class with static
methods for that to use in C# as well as C++ code.
C# didn't work well for that because I could not overload methods if they
only differ in types.
So I did the implementation in a C++ class called Units (e.g. static Double
MMtoINCH (Double MM) { return MM/(Double)25.4; } for the basic float types.
It works, but my concern is about the performance.
With VC6 the compiler would easily replace the function call by inlining the
code.
With .NET I have the IL code in an assembly which needs to be loaded and
then compiled by the JIT.
Does anyone know how good the JIT compiler handles this issue? Is he able to
do the same kind of global optimization? Do I lose performance?
Thanks
Carl
imperial to metric units and vice versa.
In VC6 I just used a simple header file with some constants (e.g. const
double MM_TO_INCH = 1.0/25.4.
For .NET I thought it might be a good idea to have a class with static
methods for that to use in C# as well as C++ code.
C# didn't work well for that because I could not overload methods if they
only differ in types.
So I did the implementation in a C++ class called Units (e.g. static Double
MMtoINCH (Double MM) { return MM/(Double)25.4; } for the basic float types.
It works, but my concern is about the performance.
With VC6 the compiler would easily replace the function call by inlining the
code.
With .NET I have the IL code in an assembly which needs to be loaded and
then compiled by the JIT.
Does anyone know how good the JIT compiler handles this issue? Is he able to
do the same kind of global optimization? Do I lose performance?
Thanks
Carl