Skip to content

Commit

Permalink
Merge pull request #44 from the9ball/chore/execute_count
Browse files Browse the repository at this point in the history
chore: add ExecuteCount to WorkloadContext
  • Loading branch information
hadashiA authored Mar 21, 2024
2 parents 0c5d71a + a11a506 commit 609be9f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sandbox/ConsoleWorker/Workloads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override Task SetupAsync(WorkloadContext context)

public override async Task ExecuteAsync(WorkloadContext context)
{
logger.LogInformation("Execute:" + (++execCount));
logger.LogInformation($"Execute:{context.ExecuteCount}");
await Task.Delay(TimeSpan.FromSeconds(1));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ await Task.WhenAll(workloads.Select((x, workloadIndex) => Task.Run(async () =>
var sw = ValueStopwatch.StartNew();
try
{
x.context.ExecuteCount = i;
await x.workload.ExecuteAsync(x.context);
}
catch (OperationCanceledException e) when (e.CancellationToken == token.Value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class WorkloadContext
public WorkloadId WorkloadId { get; }
public int WorkloadCount { get; }
public int WorkloadIndex { get; }
public long ExecuteCount { get; internal set; } = 0;
public int Concurrency { get; }
public long TotalRequestCount { get; }
public CancellationToken CancellationToken { get; }
Expand Down
1 change: 1 addition & 0 deletions src/DFrame.Worker/DFrameWorkerApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ await Task.WhenAll(workloads.Select((x, workloadIndex) => Task.Run(async () =>
var sw = ValueStopwatch.StartNew();
try
{
x.context.ExecuteCount = i;
await x.workload.ExecuteAsync(x.context);
}
catch (OperationCanceledException e) when (e.CancellationToken == token.Value)
Expand Down
1 change: 1 addition & 0 deletions src/DFrame.Worker/WorkloadContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class WorkloadContext
public WorkloadId WorkloadId { get; }
public int WorkloadCount { get; }
public int WorkloadIndex { get; }
public long ExecuteCount { get; internal set; } = 0;
public int Concurrency { get; }
public long TotalRequestCount { get; }
public CancellationToken CancellationToken { get; }
Expand Down

0 comments on commit 609be9f

Please sign in to comment.