⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 functions.html

📁 测试工具jmeter可用来进行性能测试
💻 HTML
📖 第 1 页 / 共 5 页
字号:
</tr>
<tr>
<td>last argument</td>
<td>A reference name for reusing the value computed by this function. 
                If specified, the reference name must contain at least one non-numeric character otherwise it will
                be treated as another int value to be added.
        
</td>
<td>
No
</td>
</tr>
</table>
</p>
</td></tr>
<tr><td><br></td></tr>
</table>
<hr>
<table border="0" cellspacing="0" cellpadding="2">
<tr><td>
<font face="arial,helvetica,sanserif">
<h3><a name="__longSum">19.5.4b __longSum</h3></a>
</font>
</td></tr>
<tr><td>
<p>
The longSum function can be used to compute the sum of two or more long values.

</p>
<p>
<b>Parameters</b>
<table border="1" cellspacing="0" cellpadding="2">
<tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
<tr>
<td>First argument</td>
<td>The first long value.
</td>
<td>
Yes
</td>
</tr>
<tr>
<td>Second argument</td>
<td>The second long value.
</td>
<td>
Yes
</td>
</tr>
<tr>
<td>nth argument</td>
<td>The nth long value.
</td>
<td>
No
</td>
</tr>
<tr>
<td>last argument</td>
<td>A reference name for reusing the value computed by this function. 
                If specified, the reference name must contain at least one non-numeric character otherwise it will
                be treated as another long value to be added.
        
</td>
<td>
No
</td>
</tr>
</table>
</p>
</td></tr>
<tr><td><br></td></tr>
</table>
<hr>
<a name="_StringFromFile">
</a>
<table border="0" cellspacing="0" cellpadding="2">
<tr><td>
<font face="arial,helvetica,sanserif">
<h3><a name="__StringFromFile">19.5.5 __StringFromFile</h3></a>
</font>
</td></tr>
<tr><td>

	
<p>

	The StringFromFile function can be used to read strings from a text file. 
	This is useful for running tests that require lots of variable data.
	For example when testing a banking application, 100s or 1000s of different account numbers might be required.
	
</p>

	
<p>

	See also the 
	
<a href="component_reference.html#CSV_Data_Set_Config">
CSV Data Set Config test element
</a>
 
	which may be easier to use. However, that does not currently support multiple input files.
	
</p>


	
<p>

	Each time it is called it reads the next line from the file.
	When the end of the file is reached, it will start reading again from the beginning,
	unless the maximum loop count has been reached.
	If there are multiple references to the function in a test script, each will open the file independently,
	even if the file names are the same.
	[If the value is to be used again elsewhere, use different variable names for each function call.]
	
</p>

	
<p>
If an error occurs opening or reading the file, then the function returns the string "**ERR**"
</p>


<p>
<b>Parameters</b>
<table border="1" cellspacing="0" cellpadding="2">
<tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
<tr>
<td>File Name</td>
<td>Path to the file name.
        	(The path can be relative to the JMeter launch directory)
        	If using optional sequence numbers, the path name should be suitable for passing to DecimalFormat.
        	See below for examples.
        
</td>
<td>
Yes
</td>
</tr>
<tr>
<td>Variable Name</td>
<td>
A reference name - refName - for reusing the value created by this function. Stored values are of the form ${refName}.
Defaults to "StringFromFile_".
        
</td>
<td>
No
</td>
</tr>
<tr>
<td>Start sequence number</td>
<td>Initial Sequence number (if omitted, the End sequence number is treated as a loop count)
</td>
<td>
No
</td>
</tr>
<tr>
<td>End   sequence number</td>
<td>Final sequence number (if omitted, seqence numbers can increase without limit)
</td>
<td>
No
</td>
</tr>
</table>
</p>
<p>
The file name parameter is resolved when the file is opened or re-opened.
</p>
<p>
The reference name parameter (if supplied) is resolved every time the function is executed.
</p>
<p>
<b>
Using sequence numbers:
</b>
</p>
<p>
When using the optional sequence numbers, the path name is used as the format string for java.text.DecimalFormat.
	The current sequence number is passed in as the only parameter.
    If the optional start number is not specified, the path name is used as is.
	Useful formatting sequences are:
	
</p>
<p>


<code>

# - insert the number, with no leading zeros or spaces
<br>
</br>

000 - insert the number packed out to 3 digits with leading zeros if necessary

<p>
</p>

Examples:
<br>
</br>

 pin#'.'dat -> pin1.dat, ... pin9.dat, pin10.dat, ... pin9999.dat
<br>
</br>

 pin000'.'dat -> pin001.dat ... pin099.dat ... pin999.dat ... pin9999.dat
<br>
</br>

 pin'.'dat# -> pin.dat1, ... pin.dat9 ... pin.dat999

</code>
<p>
</p>

	If more digits are required than there are formatting characters, the number will be
	expanded as necessary.
<br>
</br>

	
<b>
To prevent a formatting character from being interpreted,
	enclose it in single quotes. Note that "." is a formatting character,
	and must be enclosed in single quotes
</b>

	(though #. and 000. work as expected in locales where the decimal point is also ".")
	
<br>
</br>

	In other locales (e.g. fr), the decimal point is "," - which means that "#."
	becomes "nnn,".
<br>
</br>

	See the documentation for DecimalFormat for full details.
<br>
</br>

	If the path name does not contain any special formatting characters,
	the current sequence number will be appended to the name, otherwise
	the number will be inserted aaccording to the fomatting instructions.
<br>
</br>

	If the start sequence number is omitted, and the end sequence number is specified,
	the sequence number is interpreted as a loop count, and the file will be used at most "end" times.
	In this case the filename is not formatted.
	
<code>

	
<br>
</br>

	${_StringFromFile(PIN#'.'DAT,,1,2)} - reads PIN1.DAT, PIN2.DAT
<br>
</br>

	${_StringFromFile(PIN.DAT,,,2)} - reads PIN.DAT twice
<br>
</br>

	
</code>

	Note that the "." in PIN.DAT above should 
<u>
not
</u>
 be quoted.
	In this case the start number is omitted, so the file name is used exactly as is.
	
</p>
</td></tr>
<tr><td><br></td></tr>
</table>
<hr>
<table border="0" cellspacing="0" cellpadding="2">
<tr><td>
<font face="arial,helvetica,sanserif">
<h3><a name="__machineName">19.5.6 __machineName</h3></a>
</font>
</td></tr>
<tr><td>
<p>
The machineName function returns the local host name
</p>
<p>
<b>Parameters</b>
<table border="1" cellspacing="0" cellpadding="2">
<tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
<tr>
<td>Variable Name</td>
<td>A reference name for reusing the value
                computed by this function.
</td>
<td>
No
</td>
</tr>
</table>
</p>
</td></tr>
<tr><td><br></td></tr>
</table>
<hr>
<table border="0" cellspacing="0" cellpadding="2">
<tr><td>
<font face="arial,helvetica,sanserif">
<h3><a name="__javaScript">19.5.7 __javaScript</h3></a>
</font>
</td></tr>
<tr><td>


<p>

The javaScript function executes a piece of JavaScript (not Java!) code and returns its value

</p>


<p>

The JMeter Javascript function calls a standalone JavaScript interpreter.
Javascript is used as a scripting language, so you can do calculations etc.
</p>


<p>

For details of the language, please see 
<a href="http://www.mozilla.org/rhino/overview.html">
Mozilla Rhino Overview
</a>


</p>


<p>

The following variables are made available to the script:

</p>


<ul>


<li>
ctx - JMeterContext object
</li>


<li>
vars - JMeterVariables object
</li>


<li>
threadName - String
</li>


<li>
sampler - current Sampler object (if any)
</li>


<li>
sampleResult - previous SampleResult object (if any)
</li>


<li>
props - JMeter Properties object
</li>


</ul>


<p><table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2">
<tr><td>
JMeter is not a browser, and does not interpret the JavaScript in downloaded pages.

</td></tr>
</table></p>


<p>
<b>Parameters</b>
<table border="1" cellspacing="0" cellpadding="2">
<tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
<tr>
<td>Expression</td>
<td>The JavaScript expression to be executed. For example:
        	
<ul>

        		
<li>
new Date() - return the current date and time
</li>

        		
<li>
Math.floor(Math.random()*(${maxRandom}+1))
        			- a random number between 0 and the variable maxRandom
</li>

        		
<li>
${minRandom}+Math.floor(Math.random()*(${maxRandom}-${minRandom}+1))
        			- a random number between the variables minRandom and maxRandom
</li>

        		
<li>
"${VAR}"=="abcd"
</li>

        	
</ul>

        	
</td>
<td>
Yes
</td>
</tr>
<tr>
<td>Variable Name</td>
<td>A reference name for reusing the value
                computed by this function.
</td>
<td>
No
</td>
</tr>
</table>
</p>
<p><table border="1" bgcolor="#bbbb00" width="50%" cellspacing="0" cellpadding="2">
<tr><td>Remember to include any necessary quotes for text strings and JMeter variables. Also, if
the expression has commas, please make sure to escape them. For example in:

<br>
</br>

${__javaScript('${sp}'.slice(7\,99999))}

<br>
</br>

the comma after 7 is escaped.
</td></tr>
</table></p>
</td></tr>
<tr><td><br></td></tr>
</table>
<hr>
<table border="0" cellspacing="0" cellpadding="2">
<tr><td>
<font face="arial,helvetica,sanserif">
<h3><a name="__Random">19.5.8 __Random</h3></a>
</font>
</td></tr>
<tr><td>
<p>
The random function returns a random number that lies between the given min and max values.
</p>
<p>
<b>Parameters</b>
<table border="1" cellspacing="0" cellpadding="2">
<tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
<tr>
<td>Minimum value</td>
<td>A number
</td>
<td>
Yes
</td>
</tr>
<tr>
<td>Maximum value</td>
<td>A bigger number
</td>
<td>
Yes
</td>
</tr>
<tr>
<td>Variable Name</td>
<td>A reference name for reusing the value
                computed by this function.
</td>
<td>
No
</td>
</tr>
</table>
</p>
</td></tr>
<tr><td><br></td></tr>
</table>
<hr>
<table border="0" cellspacing="0" cellpadding="2">
<tr><td>
<font face="arial,helvetica,sanserif">
<h3><a name="__CSVRead">19.5.8 __CSVRead</h3></a>
</font>
</td></tr>
<tr><td>
<p>
The CSVFile function returns a string from a CSV file (c.f. 
<a href="#_StringFromFile">
StringFromFile
</a>
)
</p>

	
<p>
NOTE: versions up to 1.9.1 only supported a single file. 
		JMeter versions since 1.9.1 support multiple file names.
	
</p>

	
<p>
<b>
In most cases, the newer 
	
<a href="component_reference.html#CSV_Data_Set_Config">
CSV Data Set Config element
</a>

	 is easier to use.
</b>
</p>

	
<p>

	When a filename is first encountered, the file is opened and read into an internal
	array. If a blank line is detected, this is treated as end of file - this allows
	trailing comments to be used (N.B. this feature was introduced in versions after 1.9.1)
	
</p>

	
<p>
All subsequent references to the same file name use the same internal array.
	N.B. the filename case is significant to the function, even if the OS doesn't care,
	so CSVRead(abc.txt,0) and CSVRead(aBc.txt,0) would refer to different internal arrays.
	
</p>

	
<p>

	The *ALIAS feature allows the same file to be opened more than once,
	and also allows for shorter file names.
	
</p>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -