Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ namespace VirtualClient.Actions
using System.IO;
using System.IO.Abstractions;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using VirtualClient.Common;
using VirtualClient.Common.Extensions;
Expand All @@ -27,6 +25,7 @@ public class Prime95Executor : VirtualClientComponent
{
private IFileSystem fileSystem;
private IPackageManager packageManager;
private ProcessManager processManager;
private ISystemManagement systemManagement;
private List<int> successExitCodes;

Expand All @@ -41,6 +40,7 @@ public Prime95Executor(IServiceCollection dependencies, IDictionary<string, ICon
this.systemManagement = this.Dependencies.GetService<ISystemManagement>();
this.packageManager = this.systemManagement.PackageManager;
this.fileSystem = this.systemManagement.FileSystem;
this.processManager = this.systemManagement.ProcessManager;

// The exit code on SafeKill is -1 which is not a part of the default success codes.
this.successExitCodes = new List<int>(ProcessProxy.DefaultSuccessCodes) { -1 };
Expand Down Expand Up @@ -279,7 +279,7 @@ private async Task ExecuteWorkloadAsync(EventContext telemetryContext, Cancellat

await this.Logger.LogMessageAsync($"{this.TypeName}.ExecuteWorkload", telemetryContext, async () =>
{
using (IProcessProxy process = this.systemManagement.ProcessManager.CreateProcess(this.ExecutablePath, commandArguments, this.Prime95Package.Path))
using (IProcessProxy process = this.processManager.CreateProcess(this.ExecutablePath, commandArguments, this.Prime95Package.Path))
{
this.CleanupTasks.Add(() => process.SafeKill());

Expand All @@ -290,7 +290,7 @@ await this.Logger.LogMessageAsync($"{this.TypeName}.ExecuteWorkload", telemetryC
if (process.Start())
{
await this.WaitAsync(explicitTimeout, cancellationToken);
process.SafeKill();
this.processManager.Kill(new List<string> { process.Name });

if (!cancellationToken.IsCancellationRequested)
{
Expand All @@ -302,15 +302,14 @@ await this.Logger.LogMessageAsync($"{this.TypeName}.ExecuteWorkload", telemetryC
{
results = await this.fileSystem.File.ReadAllTextAsync(this.ResultsFilePath);
}

if (string.IsNullOrWhiteSpace(results))
{
throw new WorkloadResultsException(
$"Prime95 results file not found at path '{this.ResultsFilePath}'.",
ErrorReason.WorkloadResultsNotFound);
}

// The exit code on SafeKill is -1 which is not a part of the default success codes.
process.ThrowIfWorkloadFailed(this.successExitCodes);
this.CaptureMetrics(process, results, telemetryContext, cancellationToken);
}
Expand Down
4 changes: 1 addition & 3 deletions website/docs/workloads/prime95/prime95.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ The following list describes the measurements captured by the workload running a

* Number of Tests passed.
* Number of Tests failed.
* Time-to-Compute the Tests (in seconds).

## Workload Metrics
The following metrics are examples of those captured by the Virtual Client when running the Prime95 workload.
Expand All @@ -54,5 +53,4 @@ for which the system was stressed with torture test. A higher the test time with
| Metric Name | Example Value (min) | Example Value (max) | Example Value (avg) | Unit |
|--------------|---------------------|---------------------|---------------------|------|
| failTestCount | 0.0 | 0.0 | 0.0 | |
| passTestCount | 32.0 | 192.0 | 115.45833333333333 | |
| testTime | 3600.0031989 | 3601.679443 | 3600.23347608125 | seconds |
| passTestCount | 32.0 | 192.0 | 115.45833333333333 | |
Loading