I know; I'm talking about the DLL vs SO as well; have you ever looked at the code that makes up Win32API / DL? It is (mostly) written in Ruby, as well as DL. That is, and always will be, slower than using direct C function calls exposed by a C extension.
And no, my first benchmark showed that native C extensions run 20x faster than calling native C libraries through Ruby and an underlying C extension. It also had no type checking whatsoever. Win32API has internal type checking of it's own that you can't remove, and that is the bottleneck right there.
Think of it this way:
Object.some_c_extension_method# Execution stack: Look up method name in method table, call function pointer# from said method table.# This is pretty much the equivalent of referencing an# instance of Method in an array, executing that method, then returning the result.# Except faster, cause it's done C-side.SomeApiFunc.call(*vars)# Execution stack: Send vars array to be parsed Ruby-side, a string to be iterated# through Ruby-side, vars array is then passed C-side to be interated through and# converted, then the Win32API function is referenced from an internal list C-side,# then it is called C-side, and the result is converted to a Ruby object via a# Ruby-side string prototype, then the result is returned.TL;DR: Win32API and DL have Ruby boilerplate code, which is what is slowing it down. You do not directly call a native C function with Win32API / DL; with a Ruby C Extension method, you do. I think you are confused as to how Win32API and DL works, exactly.Note that both means of accessing C functions have a small amount of overhead of Ruby parsing the mehod call, no matter the means. Excluding that, A C Extension is pretty much equivalent to directly calling a C function. You have them backwards
EDIT: And, as a bonus, I can guarantee that writing a C extension that calls any Win32API function from a windows dll will be significantly faster than using Win32API, simply because of said boilerplate code, written in Ruby.
EDIT2: Sorry for the clusterfu** that is this post; I'm dealing with a little one at the moment, she just got home from school. I'll clean it up / better explain in a bit.