I tried to build a very very small .NET app in F#.
It just has to convert a small string int开发者_开发技巧o another string and print the result to the console like:
convert.exe myString ==> prints something like "myConvertedString"
I used dottrace to analyze the performance:
- 26% (168ms) in my actual string conversion (I thinks this is ok.)
- 65,80% (425ms) in ResolvePolicy in System.Security.SecurityManager
A runtime > 500ms on every execution is way too slow. Can I do something to improve this?
It would be Ok if only the first call needs this time.
Regards, forki
Do you definitely have to run this as a separate process for each string?
Could you pass in the name of a file containing a lot of strings? That would be significantly more efficient, in terms of:
- Time taken to bring up a process
- Time taken to load all the various bits of .NET
- Time taken to JIT your code
- Time taken to resolve the security policy
You could use caspol.exe to turn code access security check off.
you could try to precompile the assembly. with the program ngen it is possible to compile a .net assembly already to machine code, and then to install the assembly in the global assembly path. that should speed up the loading time of the application
精彩评论