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

Commit

Permalink
Add helper to track duration
Browse files Browse the repository at this point in the history
  • Loading branch information
jdillon committed Apr 13, 2014
1 parent 02ad9b0 commit b27121b
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -29,6 +29,8 @@ public class EventDataBuilder
{
private final EventData data = new EventData();

private final long started;

public EventDataBuilder(final String type) {
data.setType(type);
data.setTimestamp(System.nanoTime());
Expand All @@ -46,6 +48,8 @@ public EventDataBuilder(final String type) {
data.setSessionId(session.getId().toString());
}
}

this.started = System.nanoTime();
}

public EventDataBuilder set(final String name, final @Nullable Object value) {
Expand All @@ -54,6 +58,10 @@ public EventDataBuilder set(final String name, final @Nullable Object value) {
return this;
}

public EventDataBuilder setDuration(final String name) {
return set(name, System.nanoTime() - started);

This comment has been minimized.

Copy link
@mcculls

mcculls Apr 14, 2014

Contributor

If there are multiple calls to setDuration for the same builder, it is expected that they should all be relative to the same start time - or should the start time be reset after setDuration so that any subsequent call to setDuration is relative to the last call?

}

public EventData build() {
return data;
}
Expand Down

0 comments on commit b27121b

Please sign in to comment.