Skip to content

Conversation

vdaburon
Copy link
Contributor

@vdaburon vdaburon commented Sep 27, 2024

Corresponding to the issue (new feature): #6319

Description

Add a new unmodifiable JMeter Thread variable named "__jmv_THREAD_START_TIME_ITERATION"

Motivation and Context

It is interesting to know the start timestamp of a thread iteration to calculate cadences or pacing.

This variable can also be used to help other Thread Groups calculate cadences (E.g : Concurrency Thread Group or may be Open Model Thread Group)

How Has This Been Tested?

Yes, add a groovy sampler first sampler of the thread group and compute the delta between the value in the variable __jmv_THREAD_START_TIME_ITERATION and the current time System.currentTimeMillis() in the groovy sampler.

Groovy code
+++++++++++++++++++++++++++
long currentTime = System.currentTimeMillis();
long startThreadIter = Long.parseLong(vars.get("__jmv_THREAD_START_TIME_ITERATION"));
long delta = currentTime - startThreadIter;
return delta;
+++++++++++++++++++++++++++
Results 0 or 1 ms

Screenshots (if appropriate):

Types of changes

  • New feature

Checklist:

  • [x ] My code follows the code style of this project.
  • [ x] I have updated the documentation accordingly.
    Add new variable __jmv_THREAD_START_TIME_ITERATION in the documentation :
    functions.xml, section 6 Pre-defined Variables

DABURON Vincent added 2 commits September 26, 2024 15:26
…e currentTimeMillis when the thread iteration start.

Corresponding to the issue (new feature): #6319
…ntTimeMillis when the thread iteration start in the section "6 Pre-defined Variables"
<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_SAME_USER</code> - is the same user for each iteration ? <code>true</code>/<code>false</code>. Mainly impacts clean cookie, cache data and new connection</li>
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this to fix some older code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this to fix some older code?
Yes, when i search this variable "__jmv_SAME_USER" in the documentation, i don't see it.
So i add this line about the variable __jmv_SAME_USER.
And i add the new one variable "__jmv_THREAD_START_TIME_ITERATION"

@FSchumacher
Copy link
Contributor

I don't think, that this can be used by OMTG, as the thread is started by OMTG itself and not initialised, when that information is needed. But that problem is hopefully addressed by #6353 .

Apart from that, the information might be helpful for listeners or users, so LGTM.

@vdaburon vdaburon closed this by deleting the head repository Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants