[Mono-devel-list] System.Reflection Performance
lupus at ximian.com
Tue Jan 6 12:50:12 EST 2004
On 01/03/04 David Sheldon wrote:
> Is there an easy way to get the IL for a single method out of an
> assembly, or even out of mcs? I am also a little confused how to see
monodis assembly | less
and then grep.
> what the JITer does with a method. Mono has --compile METHOD, but I
> spent some time working out how to specify the name of a method for it,
> and does it output anything unless you use -v -v? Is there a better way
> than doing this. I think that these might be the sort of things that
> should go in this document.
The mono.1 manpage says:
This compiles a method (namespace.name:methodname), this is used
for testing the compiler performance or to examine the output of
the code generator.
Method overloads are handled by adding also the argument types in parens
after the method name (you can see the --profile output for examples).
You can also run your program with a few -v switches (4 or 5) to get
lots of info and the generated assembly for all the methods, then just
use grep to find the one you're looking for. You can also run mono under
gdb and use gdb's disas command.
However, looking at the generated native assembly is usually not a good
advice to give, unless you're interested in the very low level details
of the jit (99% of the people aren't).
> > * Check if the JIT makes any of the items into instructions (such
> > as String.Length).
> Could you explain this one in more detail please?
The jit can substitute some method calls or property accesses with
a small number of native instructions. Most people should just ignore
this advice, because it's bound to lead to micro optimizations that turn
out to hurt later on.
Maybe the only good advice wrt performance is: use the profiler or
otherwise time your application code and see the actual numbers
of where the most time is spent and start optimizing the high-level code
there (if it's not already fast enough) without uglyfying the code.
If it's still too slow you might want to post to the list: it may well
be you're hitting some part of the mono runtime that has not been
optimized yet, or something that requires some jit help.
lupus at debian.org debian/rules
lupus at ximian.com Monkeys do it better
More information about the Mono-devel-list