alex-hedley / BlazorInteractive

Blazor C# Interactive (Try .NET)
https://alex-hedley.github.io/BlazorInteractive/
MIT License
3 stars 0 forks source link

Stats #14

Open alex-hedley opened 1 year ago

alex-hedley commented 1 year ago

Stats

Last Run: 10:16:27 am
Compile: 0.156s
Execute: 0.016s
Memory: 0b
CPU: 0.016s
alex-hedley commented 1 year ago

Speeding up CSharpCompilation.Emit? https://stackoverflow.com/questions/62625367/speeding-up-csharpcompilation-emit

private static T Measure<T>(string caption, Func<T> generator)
{
    var now = DateTime.Now;
    var result = generator();
    var end = DateTime.Now - now;
    Debug.WriteLine($"{caption}: {end.TotalMilliseconds} ms");
    return result;
}
var compilation = Measure("Compile", () => CSharpCompilation.Create(
    "Bar.dll",
    new[] {syntaxTree},
    typeRefs.Select(x => MetadataReference.CreateFromFile(x)),
    new CSharpCompilationOptions(
        OutputKind.DynamicallyLinkedLibrary,
        optimizationLevel: OptimizationLevel.Debug
    )
));

Compile: 43,4261 ms

TheDanielDoyle commented 1 year ago

Possibly use example:

https://www.csharpstar.com/measure-memory-usage-of-your-application-csharp/