cs-codex-dist-tests/Tools/AutoClient/Performance.cs

64 lines
1.5 KiB
C#
Raw Normal View History

using Logging;
namespace AutoClient
2024-09-12 12:38:15 +00:00
{
public class Performance
{
private readonly ILog log;
public Performance(ILog log)
{
this.log = log;
}
public void DownloadFailed(Exception ex)
{
Log($"Download failed: {ex}");
}
public void DownloadSuccessful(long size, TimeSpan time)
2024-09-12 12:38:15 +00:00
{
long seconds = Convert.ToInt64(time.TotalSeconds);
long bytesPerSecond = size / seconds;
Log($"Download successful: {bytesPerSecond} bytes per second");
2024-09-12 12:38:15 +00:00
}
public void StorageContractCancelled()
2024-09-12 12:38:15 +00:00
{
Log("Contract cancelled");
2024-09-12 12:38:15 +00:00
}
public void StorageContractErrored(string error)
2024-09-12 12:38:15 +00:00
{
Log($"Contract errored: {error}");
2024-09-12 12:38:15 +00:00
}
public void StorageContractFinished()
2024-09-12 12:38:15 +00:00
{
Log("Contract finished");
2024-09-12 12:38:15 +00:00
}
public void StorageContractStarted()
2024-09-12 12:38:15 +00:00
{
Log("Contract started");
2024-09-12 12:38:15 +00:00
}
public void UploadFailed(Exception ex)
2024-09-12 12:38:15 +00:00
{
Log($"Upload failed: {ex}");
2024-09-12 12:38:15 +00:00
}
public void UploadSuccessful(long size, TimeSpan time)
2024-09-12 12:38:15 +00:00
{
long seconds = Convert.ToInt64(time.TotalSeconds);
long bytesPerSecond = size / seconds;
Log($"Upload successful: {bytesPerSecond} bytes per second");
2024-09-12 12:38:15 +00:00
}
private void Log(string msg)
2024-09-12 12:38:15 +00:00
{
log.Log(msg);
2024-09-12 12:38:15 +00:00
}
}
}