Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Clean up ack handling, fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
whesse committed Jan 22, 2024
1 parent 8a2c57f commit 3010760
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
31 changes: 16 additions & 15 deletions lib/src/benchmark_base_perf.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,7 @@ class BenchmarkBase extends base.BenchmarkBase {
if (perfControlAck != null) {
openedAck = File(perfControlAck!).openSync();
openedFifo.writeStringSync('enable\n');

var ack = <int>[...openedAck.readSync(4)];
while (ack.length < 4) {
ack.addAll(openedAck.readSync(4 - ack.length));
print('reading $ack');
}
if (String.fromCharCodes(ack) != 'ack\n') {
print('Ack was $ack');
}
/* var ackLength = 0;
while (ackLength < 4) {
ackLength += openedAck.readSync(4 - ackLength).length;
print('reading $ackLength');
}*/
waitForAck();
} else {
openedFifo.writeStringSync('enable\n');
}
Expand All @@ -52,8 +39,22 @@ class BenchmarkBase extends base.BenchmarkBase {
if (perfControlFifo != null) {
openedFifo.writeStringSync('disable\n');
openedFifo.closeSync();
if (perfControlAck != null) {
waitForAck();
openedAck.closeSync();
}
emitter.emit('$name.totalIterations', totalIterations.toDouble());
}
// TODO: await ack.
}

void waitForAck() {
var ack = <int>[...openedAck.readSync(4)];
while (ack.length < 4) {
ack.addAll(openedAck.readSync(4 - ack.length));
print('reading $ack');
}
if (String.fromCharCodes(ack) != 'ack\n') {
print('Ack was $ack');
}
}
}
2 changes: 1 addition & 1 deletion test/result_emitter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MockResultEmitter extends ScoreEmitter {

// Create a new benchmark which has an emitter.
class BenchmarkWithResultEmitter extends BenchmarkBase {
const BenchmarkWithResultEmitter(ScoreEmitter emitter)
BenchmarkWithResultEmitter(ScoreEmitter emitter)
: super('Template', emitter: emitter);

@override
Expand Down

0 comments on commit 3010760

Please sign in to comment.