如何解决如何修复 Xamarin BenchmarkDotNet 错误“只读文件系统”?
我正在使用 xamarin 创建移动应用程序。 我想使用 BenchmarkDotNet 对某些功能进行基准测试。 当我从 github 运行代码时,它工作正常。 这是截图
但是当我在我的代码中实现它返回 System.IO.IOException: Read-only file system
。
这是完整的堆栈跟踪
{System.IO.IOException: Read-only file system
at System.IO.FileSystem.CreateDirectory (System.String fullPath) [0x00187] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.IO.FileSystem/src/System/IO/FileSystem.Unix.cs:317
at System.IO.Directory.CreateDirectory (System.String path) [0x0002c] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.IO.FileSystem/src/System/IO/Directory.cs:40
at BenchmarkDotNet.Extensions.CommonExtensions.CreateIfNotExists (System.String directoryPath) [0x00008] in <f652b77bc59948ee97aa060ee522cb56>:0
at BenchmarkDotNet.Running.BenchmarkRunnerClean.GetResultsFolderPath (System.String rootArtifactsFolderPath,BenchmarkDotNet.Running.BenchmarkRunInfo[] benchmarkRunInfos) [0x00050] in <f652b77bc59948ee97aa060ee522cb56>:0
at BenchmarkDotNet.Running.BenchmarkRunnerClean.Run (BenchmarkDotNet.Running.BenchmarkRunInfo[] benchmarkRunInfos) [0x0001a] in <f652b77bc59948ee97aa060ee522cb56>:0
at BenchmarkDotNet.Running.BenchmarkRunner.RunWithDirtyAssemblyResolveHelper (System.Type type,BenchmarkDotNet.Configs.IConfig config) [0x0000f] in <f652b77bc59948ee97aa060ee522cb56>:0
at BenchmarkDotNet.Running.BenchmarkRunner+<>c__displayClass0_0`1[T].<Run>b__0 () [0x00000] in <f652b77bc59948ee97aa060ee522cb56>:0
at BenchmarkDotNet.Running.BenchmarkRunner.RunWithExceptionHandling (System.Func`1[TResult] run) [0x00000] in <f652b77bc59948ee97aa060ee522cb56>:0
at BenchmarkDotNet.Running.BenchmarkRunner.Run[T] (BenchmarkDotNet.Configs.IConfig config) [0x00013] in <f652b77bc59948ee97aa060ee522cb56>:0
at KisahMobile.Benchmark.BenchmarkMachine+<>c__displayClass0_0.<RunAsync>b__0 () [0x0000f] in D:\Bitbucket\ptgdi.kisahmobile\KisahMobile\KisahMobile\KisahMobile\Benchmark\BenchmarkMachine.cs:25
at System.Threading.Tasks.Task.InnerInvoke () [0x0000f] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2476
at System.Threading.Tasks.Task.Execute () [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2319
--- End of stack trace from prevIoUs location where exception was thrown ---
at KisahMobile.Benchmark.BenchmarkMachine.RunAsync () [0x00046] in D:\Bitbucket\ptgdi.kisahmobile\KisahMobile\KisahMobile\KisahMobile\Benchmark\BenchmarkMachine.cs:19
at KisahMobile.PagesModels.HomePageModel.HandletoNotif () [0x00023] in D:\Bitbucket\ptgdi.kisahmobile\KisahMobile\KisahMobile\KisahMobile\PagesModels\HomePageModel.cs:245 }
这是基准代码
public static class BenchmarkMachine
{
public static async Task<string> RunAsync()
{
var logger = new AccumulationLogger();
await Task.Run(() =>
{
var config = default(IConfig);
#if DEBUG
config = new DebugInProcessConfig();
#endif
var summary = BenchmarkRunner.Run<CommonBenchmark>(config);
MarkdownExporter.Console.ExportToLog(summary,logger);
ConclusionHelper.Print(logger,summary.BenchmarksCases
.SelectMany(benchmark => benchmark.Config.GetCompositeAnalyser().Analyse(summary))
.distinct()
.ToList());
});
return logger.GetLog();
}
}
[MemoryDiagnoser]
[Orderer(SummaryOrderPolicy.FastestToslowest)]
[RankColumn]
public class CommonBenchmark
{
[Benchmark]
public void Sleep()
{
var rand = new Random();
List<int> vs = new List<int>();
for (int i = 0; i < 100; i++)
{
vs.Add(rand.Next(0,100000));
}
}
}
我使用此代码运行基准测试
string result = await BenchmarkMachine.RunAsync();
我很困惑为什么我的代码不能像 github 中的示例那样工作。 有什么解决办法吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。