benchCodec function

void benchCodec(
  1. Codec<List<int>, List<int>> codec,
  2. List<int> input
)

Implementation

void benchCodec(Codec<List<int>, List<int>> codec, List<int> input) {
  Stopwatch sw1 = new Stopwatch()..start();
  List<int> encoded;
  for (int i = 0; i < 100; i++) {
    encoded = codec.encode(input);
  }
  sw1.stop();
  Stopwatch sw2 = new Stopwatch()..start();
  for (int i = 0; i < 100; i++) {
    codec.decode(encoded);
  }
  sw2.stop;
  print([
    (encoded.length * 100 / input.length).toStringAsFixed(2),
    sw1.elapsedMilliseconds,
    sw2.elapsedMilliseconds,
  ]);
}