Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Using scheduled start-time instead of actual start-time #56

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,27 @@ private void runTest(final int durationSeconds, final int messageRate)
}

int workCount = 0;

final long now = clock.nanoTime();

if (moreToGenerate && now - nextMessageAt >= 0)
{
generationTimestamps[freePosition++] = now;

workCount += trySend();
int trySend = trySend(nextMessageAt);

generatedMessages++;
nextMessageAt += periodNs;
if (trySend == 0)
{
freePosition--;
}
else
{
workCount += trySend;
generatedMessages++;
nextMessageAt += periodNs;
}

// todo: not sure what to do with this section.
if (now - nextMessageAt >= 0)
{
fallingBehindCount++;
Expand All @@ -256,8 +266,6 @@ private void runTest(final int durationSeconds, final int messageRate)

workCount += transceiver.receive();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this second trySend done? You only want to send when a request is scheduled and that is taken care of by the above if-statement.

workCount += trySend();

if (now - deadline >= 0)
{
throw new RuntimeException("Timed out");
Expand Down Expand Up @@ -285,15 +293,14 @@ private void runTest(final int durationSeconds, final int messageRate)
out.println("Stats: fallingBehindCount=" + fallingBehindCount);
}

private int trySend()
private int trySend(final long timestamp)
{
if (!synced || sendPosition >= freePosition)
{
return 0;
}

final int sequence = sendPosition;
final long timestamp = generationTimestamps[sendPosition];

if (transceiver.trySendEcho(sequence, timestamp))
{
Expand Down
Loading