在ASP.net MVC中使用benchmarkdotnet获取性能结果

4

我正在测试基准库来衡量代码的性能。我正在阅读文档。

我无法弄清楚如何打印基准测试结果。我有一个名为"user"的类,我想对以下方法进行基准测试。

[Benchmark]
public bool FollowerAdded(User newFollower)
{
    // code for notifying user that they have an added follower
    Notification notification = new Notification();
    return notification.NotifyUser(this, newFollower.UserName + " is now following you!");
}

在 benchmarkdot net 的文档中,使用以下代码获取基准测试的输出。
var summary = BenchmarkRunner.Run<User>();

在Asp.net MVC应用程序中,我们应该将这段代码放在哪里才能获得基准测试结果?以下是该库的URL链接:http://benchmarkdotnet.org/GettingStarted.htm
1个回答

1
有点晚,但是开始吧,
可能你需要一个控制台应用程序项目来引用你的库并运行基准测试,在运行后结果将会在控制台上打印出来,而报告则位于
summary.ResultsDirectoryPath

通常情况下。
$(TargetDir)BenchmarkDotNet.Artifacts\results\

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接