Skip to content
Enes Okullu edited this page May 8, 2024 · 7 revisions

CalculateETA has several methods for single thread applications. All methods calculates left count of the loop, average passed time and multiply of left count and average passed time then returns it.

CalcETA by elapsed time in milliseconds.

// 15th of the loop.
// 85 (100-15) iteration left to go.
// 15.000 milliseconds passed.
// Each iteration takes (15000/15 = 1.000 ms) a second.
// 85 left iterations will take 85 * 1.000 ms.
CalcETA(index: 15, totalIndex: 100, elapsed: 15000);

1

CalcETA(int? index, int? totalIndex, long? elapsed);
CalcETAUnsafe(int? index, int? totalIndex, long? elapsed);
CalcETA(uint? index, uint? totalIndex, long? elapsed);
CalcETAUnsafe(uint? index, uint? totalIndex, long? elapsed);

Returns null if any of parameter is null or returns estimated left time in milliseconds (long?)

  • int?/uint? index: Current index of loop. Index must not be zero.
  • int?/uint? totalIndex: Total index of loop.
  • long? elapsed: Passed time of loop in milliseconds.

CalcETA by elapsed time in ticks.

2

CalcETA(int? index, int? totalIndex, long? elapsedTicks, long? frequency);
CalcETAUnsafe(int? index, int? totalIndex, long? elapsedTicks, long? frequency);
CalcETA(uint? index, uint? totalIndex, long? elapsedTicks, long? frequency);
CalcETAUnsafe(uint? index, uint? totalIndex, long? elapsedTicks, long? frequency);

Returns null if any of parameter is null or returns estimated left time in milliseconds (long?)

  • int?/uint? index: Current index of loop. Index must not be zero.
  • int?/uint? totalIndex: Total index of loop.
  • long? elapsedTicks: Passed ticks of loop.
  • long? frequency: Tick of frequency. Frequency must not be zero.

CalcETA by elapsed time in TimeSpan.

3

CalcETA(int? index, int? totalIndex, TimeSpan? timeSpan);
CalcETAUnsafe(int? index, int? totalIndex, TimeSpan? timeSpan);
CalcETA(uint? index, uint? totalIndex, TimeSpan? timeSpan);
CalcETAUnsafe(uint? index, uint? totalIndex, TimeSpan? timeSpan);

Returns null if any of parameter is null or returns estimated left time in milliseconds (double?)

  • int?/uint? index: Current index of loop. Index must not be zero.
  • int?/uint? totalIndex: Total index of loop.
  • TimeSpan? timeSpan: Passed time of loop in TimeSpan format.

Output

  • CalcETA1(5, 10, 1000) => (long)1000
  • CalcETA2(5, 20, 50000000, 10000000) => (long)15
  • CalcETA3(5, 20, new TimeSpan(0, 0, 1, 5) => (double)195
Clone this wiki locally