Skip to Content
.NET Common Language Runtime Unleashed
book

.NET Common Language Runtime Unleashed

by Kevin Burton
April 2002
Intermediate to advanced content levelIntermediate to advanced
1024 pages
23h 26m
English
Sams
Content preview from .NET Common Language Runtime Unleashed

Performance Considerations with P/Invoke

As you probably already guessed, all of the nice things that the runtime does for you as you call unmanaged code don't come for free. However, the picture is not bleak enough for you to consider dumping interop with unmanaged code for a full port or other options.

It is estimated that each P/Invoke call requires between 10 and 30 x86 assembly instructions. This means that the overhead is small. Perhaps you have a 1Ghz Pentium and each of those 30 instructions takes one clock cycle to complete. That would mean that the overhead for a P/Invoke call is approximately 0.03 microseconds. Even if each instruction took two clock cycles to complete, that would still only be 0.06 microseconds. Clearly, the overhead ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Customizing the Microsoft® .NET Framework Common Language Runtime

Customizing the Microsoft® .NET Framework Common Language Runtime

Steven Pratschner

Publisher Resources

ISBN: 0672321246Purchase book