I can't understand example in wiki "Multiple User Defined Statistic In nGrinder" #721
-
# -*- coding:utf-8 -*-
# A simple example using the HTTP plugin that shows the retrieval of a
# single page via HTTP.
#
# This script is auto generated by ngrinder.
#
# @author admin
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from net.grinder.plugin.http import HTTPRequest
from net.grinder.plugin.http import HTTPPluginControl
from java.util import Random
control = HTTPPluginControl.getConnectionDefaults()
# if you don't want that HTTPRequest follows the redirection, please modify the following option 0.
# control.followRedirects = 1
# if you want to increase the timeout, please modify the following option.
control.timeout = 6000
test1 = Test(1, "Test1")
request1 = HTTPRequest()
#grinder.statistics.registerDataLogExpression("Delivery time", "userLong0")
grinder.statistics.registerSummaryExpression("User_defined", "(/ userLong0(+ (count timedTests)))")
# Make any method call on request1 increase TPS
test1.record(request1)
random = Random()
class TestRunner:
# initlialize a thread
def __init__(self):
grinder.statistics.delayReports=True
pass
# test method
def __call__(self):
result = request1.GET("http://www.naver.com")
# do something
deliveryTime = random.nextInt(1000)
grinder.sleep(deliveryTime)
grinder.logger.info("deliveryTime: %d" % deliveryTime)
grinder.statistics.forLastTest.setLong("userLong0", deliveryTime)
if result.getStatusCode() == 200 :
grinder.statistics.forLastTest.success = 1
elif result.getStatusCode() in (301, 302) :
grinder.logger.warn("Warning. The response may not be correct. The response code was %d." % result.getStatusCode())
grinder.statistics.forLastTest.success = 1
else :
grinder.statistics.forLastTest.success = 0 In this example, registerSummaryExpression register expression (/ userLong0(+ (count timedTests))). |
Beta Was this translation helpful? Give feedback.
Answered by
imbyungjun
Dec 29, 2020
Replies: 2 comments 3 replies
-
Refer to the grinder's guide. |
Beta Was this translation helpful? Give feedback.
1 reply
-
infix is invalid |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
donggyu04
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
infix is invalid