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

Add new thread variable __jmv_THREAD_START_TIME_ITERATION contains the currentTimeMillis when the thread iteration start. #6356

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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): apache#6319
…ntTimeMillis when the thread iteration start in the section "6 Pre-defined Variables"
@@ -1765,6 +1765,8 @@ 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_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"

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