Skip to content
Open
Show file tree
Hide file tree
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 @@ -722,6 +722,7 @@ private static void setLastSampleOk(JMeterVariables variables, boolean value) {
*/
private IterationListener initRun(JMeterContext threadContext) {
threadVars.putObject(JMeterVariables.VAR_IS_SAME_USER_KEY, isSameUserOnNextIteration);
threadVars.putObject(JMeterVariables.VAR_THREAD_START_TIME_ITERATION, threadVars.getStartThreadTimeIteration());
threadContext.setVariables(threadVars);
threadContext.setThreadNum(getThreadNum());
setLastSampleOk(threadVars, true);
Expand Down Expand Up @@ -1019,6 +1020,8 @@ private void delay(List<? extends Timer> timers) {

void notifyTestListeners() {
threadVars.incIteration();
threadVars.resetStartThreadTimeIteration();
threadVars.putObject(JMeterVariables.VAR_THREAD_START_TIME_ITERATION, threadVars.getStartThreadTimeIteration());
for (TestIterationListener listener : testIterationStartListeners) {
listener.testIterationStart(new LoopIterationEvent(threadGroupLoopController, threadVars.getIteration()));
if (listener instanceof TestElement testElement) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class JMeterVariables {
private final Map<String, Object> variables = new HashMap<>();

private int iteration = 0;
private long startTimeThreadIteration = System.currentTimeMillis();

// Property names to preload into JMeter variables:
private static final String [] PRE_LOAD = {
Expand All @@ -43,6 +44,7 @@ public class JMeterVariables {
};

static final String VAR_IS_SAME_USER_KEY = "__jmv_SAME_USER";
static final String VAR_THREAD_START_TIME_ITERATION ="__jmv_THREAD_START_TIME_ITERATION";

/**
* Constructor, that preloads the variables from the JMeter properties
Expand Down Expand Up @@ -178,4 +180,12 @@ public Set<Map.Entry<String, Object>> entrySet(){
public boolean isSameUserOnNextIteration() {
return Boolean.TRUE.equals(variables.get(VAR_IS_SAME_USER_KEY));
}

public void resetStartThreadTimeIteration() {
startTimeThreadIteration = System.currentTimeMillis();
}

public long getStartThreadTimeIteration() {
return startTimeThreadIteration;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ public String get(String key) {
return variables.get(key);
}

@Override
public long getStartThreadTimeIteration() {
return variables.getStartThreadTimeIteration();
}

@Override
public void resetStartThreadTimeIteration() {
throw new UnsupportedOperationException();
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
Expand Down
1 change: 1 addition & 0 deletions xdocs/usermanual/functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1765,6 +1765,7 @@ However some variables are defined internally by JMeter. These are listed below.
<li><code>JMeterThread.last_sample_ok</code> - whether or not the last sample was OK - <code>true</code>/<code>false</code>.
Note: this is updated after PostProcessors and Assertions have been run.
</li>
<li><code>__jmv_THREAD_START_TIME_ITERATION</code> - contains the epoch unit milliseconds of the thread start iteration. Call function System.currentTimeMillis()</li>
<li><code>START</code> variables (see next section)</li>
</ul>
</subsection>
Expand Down
Loading