toString method

  1. @override
String toString({
  1. bool withStartTime = true,
})
override

Returns a String with information of this chronometer:

  • If withTime is true will add startTime and elapsedTime to the String.

Example:

  Backpropagation{elapsedTime: 2955 ms, hertz: 2030456.8527918782 Hz, ops: 6000000, startTime: 2021-04-30 22:16:54.437147, stopTime: 2021-04-30 22:16:57.392758}

Implementation

@override
String toString({bool withStartTime = true}) {
  var timeStr = '';

  if (withStartTime && _startTime != null) {
    var start = _startTime.toString();
    var now = DateTime.now().toStringDifference(_startTime!);
    timeStr = ' · start: $start .. $now';
  }

  var totalOperation = this.totalOperation;

  var timeToCompleteStr = totalOperation != null
      ? ' · ETOC: ${timeToComplete().toStringUnit(decimal: true)}'
      : '';

  var opsRatio = totalOperation != null
      ? ' » ${(operations / totalOperation).toPercentage()}'
      : '';

  var opsFails =
      failedOperations != 0 ? ' (fails: $failedOperationsAsString)' : '';

  return '$name{ ${elapsedTime.toStringUnit(decimal: true)} · hertz: $hertzAsString · ops: $operationsAsString$opsRatio$opsFails$timeToCompleteStr$timeStr }';
}