|
|
|
|||||
|
Quote:
1) For SetConsoleCtrlHandler, the Console.CancelKeyPressEvent would be an alternative, as long as all you care about is capturing Ctrl+C and Ctrl+Break. 2) It looks as if Guid.NewGuid() does the same as UUIDCreate in rpcrt4.dll. 3) It seems there is also a managed alternative for libbz2.dll: .NET Zip Library #ziplib (SharpZipLib) Karl |
|
||||||
|
How much of a performance cost are you willing to bear? Some of the marshaling code is also unsafe -- this could be replaced with safe code but its quite a bit slower.
What environments you are considering that require fully manged code? |
|
|||||
|
Quote:
I have looked at your ByteBuffer class, the only place where I found unsafe code. I think the overall performance impact might not be as bad. It appears the unsafe code is mostly used for marshaling value types. For example, once could replace the unsafe getShort() and putShort() methods with this (untested!) code: Code:
private const UInt16 ByteLoMask = 0x00FF;
public short getShort()
{
unchecked {
checkUnderflow(2);
int ret;
if(NO._o == _order)
{
ret = (_bytes[_position] << 8;
ret |= _bytes[_position + 1];
}
else
{
ret = _bytes[_position + 1] << 8;
ret |= _bytes[_position];
}
position += 2;
return (short)ret;
}
}
public ByteBuffer putShort(short val)
{
unchecked {
checkOverflow(2);
if(NO._o == _order)
{
_bytes[_position] = (byte)(value >> 8);
_bytes[_position + 1] = (byte)(value & ByteLoMask);
}
else
{
_bytes[_position + 1] = (byte)(value >> 8);
_bytes[_position] = (byte)(value & ByteLoMask);
}
_position += 2;
}
return this;
}
Karl |
|
||||||
|
I agree that getting rid of the P/Invoke calls and the unsafe code would be nice. I wasn't aware that there is a .NET compression library available now--it's worth a try.
It will still be difficult to get rid off all the P/Invoke code though. We are using it for monotonic time, and CancelKeyPressEvent doesn't deal with window closure, logoff, and shutdown events (which SetConsoleCtrlHandler does). Cheers, Michi. |
|
||||||
|
Its also possible to use BitConverter. At any rate, for sure its slower depending on what your application is doing (for example, marshaling an array of shorts or similar). The question is whether this matters to you
![]() |
|
|||||
|
Quote:
In my measurements, the safe code was most of the time *faster* than the unsafe code (it varied from one test run to the other). I also uncovered one specific *huge* performance issue with your code: if it has to reverse the byte order, the unsafe code is more than 10 times as slow as the safe code. This is normally the case on little-endian CPUs, i.e. almost always. The reason I think is the use of all those Buffer.SetByte/GetByte calls that are obviously not inlined by the compiler. My CPU is an Athlon x64 dual core 3600. If you like, I can send you the VS 2005 project (just tell where to) so that you can check for yourself and try it on other CPUs. Karl |
|
|||||
|
Quote:
Regarding SetConsoleCtrlHandler : It is only used in your helper class, so it is not an essential part of IceCS. Maybe one could spin off non-essential classes into a separate assembly? Karl |
|
||||||
|
Quote:
Quote:
Quote:
Thanks, Michi. |
|
|||||
|
Quote:
Karl |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| icecs.dll and Mono | kwaclaw | Comments | 1 | 11-15-2007 07:28 PM |
| Mono and IceSSL Status | tkrieger | Help Center | 6 | 11-10-2006 08:29 AM |
| IcePack + Debian Linux + Mono + NoEndpointException | kovacm | Bug Reports | 10 | 07-20-2005 06:29 AM |
| Problems compiling IceCS with mono on Fedora Core 3 | iostream | Help Center | 5 | 12-10-2004 05:52 PM |
| mono c# on win32 | panic | Help Center | 5 | 12-13-2003 07:14 PM |