You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by dc...@apache.org on 2024/10/30 22:57:19 UTC
(cassandra-accord) 05/06: now track duration to show what steps are taking time
This is an automated email from the ASF dual-hosted git repository.
dcapwell pushed a commit to branch poc/harry-on-accord
in repository https://gitbox.apache.org/repos/asf/cassandra-accord.git
commit 90759ca5562676e4f94c67f552a737a502f406d2
Author: David Capwell <dc...@apache.org>
AuthorDate: Wed Oct 30 10:52:27 2024 -0700
now track duration to show what steps are taking time
---
.../src/test/java/accord/utils/Property.java | 36 ++++++++++++++++++----
1 file changed, 30 insertions(+), 6 deletions(-)
diff --git a/accord-core/src/test/java/accord/utils/Property.java b/accord-core/src/test/java/accord/utils/Property.java
index 2dfba165..f76ee293 100644
--- a/accord-core/src/test/java/accord/utils/Property.java
+++ b/accord-core/src/test/java/accord/utils/Property.java
@@ -19,6 +19,7 @@
package accord.utils;
import accord.utils.async.TimeoutUtils;
+import org.agrona.collections.LongArrayList;
import java.time.Duration;
import java.util.ArrayList;
@@ -445,6 +446,7 @@ public class Property
{
State state = null;
List<String> history = new ArrayList<>(steps);
+ LongArrayList historyTiming = stepTimeout == null ? null : new LongArrayList();
try
{
checkInterrupted();
@@ -469,18 +471,18 @@ public class Property
for (Command<State, SystemUnderTest, ?> sub : ((MultistepCommand<State, SystemUnderTest>) cmd))
{
history.add(sub.detailed(state));
- process(sub, state, sut, history.size());
+ process(sub, state, sut, history.size(), historyTiming);
}
}
else
{
history.add(cmd.detailed(state));
- process(cmd, state, sut, history.size());
+ process(cmd, state, sut, history.size(), historyTiming);
}
}
commands.destroySut(sut, null);
commands.destroyState(state, null);
- commands.onSuccess(state, sut, history);
+ commands.onSuccess(state, sut, maybeRewriteHistory(history, historyTiming));
}
catch (Throwable t)
{
@@ -498,7 +500,8 @@ public class Property
}
catch (Throwable t)
{
- throw new PropertyError(statefulPropertyError(this, t, state, history), t);
+
+ throw new PropertyError(statefulPropertyError(this, t, state, maybeRewriteHistory(history, historyTiming)), t);
}
if (pure)
{
@@ -508,14 +511,35 @@ public class Property
}
}
- private <State, SystemUnderTest> void process(Command cmd, State state, SystemUnderTest sut, int id) throws Throwable
+ private static List<String> maybeRewriteHistory(List<String> history, @Nullable LongArrayList historyTiming)
+ {
+ if (historyTiming == null) return history;
+ List<String> newHistory = new ArrayList<>(history.size());
+ for (int i = 0; i < history.size(); i++)
+ {
+ String step = history.get(i);
+ long timeNanos = historyTiming.getLong(i);
+ newHistory.add(step + ";\tDuration " + Duration.ofNanos(timeNanos));
+ }
+ return newHistory;
+ }
+
+ private <State, SystemUnderTest> void process(Command cmd, State state, SystemUnderTest sut, int id, @Nullable LongArrayList stepTiming) throws Throwable
{
if (stepTimeout == null)
{
cmd.process(state, sut);
return;
}
- TimeoutUtils.runBlocking(stepTimeout, "Stateful Step " + id + ": " + cmd.detailed(state), () -> cmd.process(state, sut));
+ long startNanos = System.nanoTime();
+ try
+ {
+ TimeoutUtils.runBlocking(stepTimeout, "Stateful Step " + id + ": " + cmd.detailed(state), () -> cmd.process(state, sut));
+ }
+ finally
+ {
+ stepTiming.add(System.nanoTime() - startNanos);
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org