Implement lazily-computed variables
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.3k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 5
Description
### Use case
JMeter often exposes "magic variables".
For instance
* `Regex Extractor` has `Reference Name` configuration (see https://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor), and it exposes `refName_gn`, `refName_g`, `refName_matchNr`, and similar variables even in the case user never actually queries them
* `IteratingController` exposes `iteration number` magic variable, which is visible in the profiling reports (see https://github.com/apache/jmeter/issues/5875#issuecomment-1533369880)
See also:
* https://github.com/apache/jmeter/issues/4606#issuecomment-1553289568
* https://github.com/apache/jmeter/issues/5875#issuecomment-1533369880
### Possible solution
Add a possibility to expose a variable that is compute lazily.
For instance, add `interface LazyVariable { T getValue(); }`, then if somebody adds a variable with value that implements `LazyVariable`, then each retrieval would call `getValue()`.
Additionally, it might be useful to register "automatic-named" variable resolution.
For instance, for `Regex Extractor`, it might be great to be able to register all `refName_g0`, `refName_g1`, `refName_g2`, ..., `refName_g999` as a single registration like `refName_g[0-9]+` or `refName_g*` or something like that, then JMeter could resolve the variable only in case the user requests it. Of course, the implementation must not execute the regexp over all the registrations on each `get` (I believe it is possible).
### Possible workarounds
_No response_
### JMeter Version
5.5
### Java Version
_No response_
### OS Version
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.