mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-14 20:48:00 +00:00
Add Xamarin support to the ORT nuget packages. - Update C# code to support Xamarin builds for iOS and Android - refactor some things to split out common code - include iOS and Android ORT native shared library in native nuget package
52 lines
No EOL
1.7 KiB
C#
52 lines
No EOL
1.7 KiB
C#
using System;
|
|
using System.Collections.Concurrent;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using Newtonsoft.Json;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Microsoft.ML.OnnxRuntime.Tests.Devices
|
|
{
|
|
public class TestResultProcessor
|
|
{
|
|
ConcurrentBag<TestResult> _results = new ConcurrentBag<TestResult>();
|
|
|
|
public ConcurrentBag<TestResult> Results
|
|
{
|
|
get => _results == null ? (_results = new ConcurrentBag<TestResult>()) : _results;
|
|
private set => _results = value;
|
|
}
|
|
|
|
internal void RecordResult(TestResult test)
|
|
=> Results.Add(test);
|
|
|
|
public void RecordResult(ITestResultMessage testResult, ITestCase testCase, TestOutcome outcome)
|
|
{
|
|
try
|
|
{
|
|
RecordResult(new TestResult
|
|
{
|
|
TestId = testCase.UniqueID,
|
|
TestName = testCase.DisplayName,
|
|
Output = testResult.Output,
|
|
TestOutcome = outcome,
|
|
Duration = TimeSpan.FromSeconds((double)testResult.ExecutionTime).ToString("c", CultureInfo.InvariantCulture)
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
System.Diagnostics.Trace.TraceError(ex.Message);
|
|
}
|
|
}
|
|
|
|
public TestResultSummary GetResults()
|
|
=> new TestResultSummary(Results.ToList());
|
|
|
|
public string GetSerializedResults()
|
|
{
|
|
var resultSummary = GetResults();
|
|
var serializedResultSummary = JsonConvert.SerializeObject(resultSummary, Formatting.Indented);
|
|
return serializedResultSummary;
|
|
}
|
|
}
|
|
} |