Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用java代码使用JMeterAPI中的吞吐量成形计时器?_Jmeter - Fatal编程技术网

如何使用java代码使用JMeterAPI中的吞吐量成形计时器?

如何使用java代码使用JMeterAPI中的吞吐量成形计时器?,jmeter,Jmeter,我想在java代码中使用使用JMeterAPI的吞吐量成形计时器 我的目的是通过JMeterAPI在代码中以编程方式使用吞吐量成形计时器 我已经通过将名为VariableThroughputTimer.java的类文件添加到项目文件夹的源目录中引用了该类文件 以下是我的代码片段的一部分: // VariableThroughputTimer VariableThroughputTimer timer = new VariableThroughputTimer(); ti

我想在java代码中使用使用JMeterAPI的吞吐量成形计时器

我的目的是通过JMeterAPI在代码中以编程方式使用吞吐量成形计时器

我已经通过将名为VariableThroughputTimer.java的类文件添加到项目文件夹的源目录中引用了该类文件

以下是我的代码片段的一部分:

   //   VariableThroughputTimer
    VariableThroughputTimer timer = new VariableThroughputTimer();
    timer.setEnabled(true);
    timer.setName("VariableThroughputTimer");
    timer.setProperty("Start RPS", 1);
    timer.setProperty("End RPS", 1000);
    timer.setProperty("Duration", 60);
    timer.setComment("Table below sets request rate shcedule ant preview graph instantly shows effect of changes.");
    timer.setProperty(TestElement.TEST_CLASS, kg.apc.jmeter.vizualizers.CorrectedResultCollector.class.getName());
    timer.setProperty(TestElement.GUI_CLASS, kg.apc.jmeter.vizualizers.TransactionsPerSecondGui.class.getName());


    // Thread Group
    ThreadGroup threadGroup = new ThreadGroup();
    threadGroup.setName("Thread Group");
    threadGroup.setNumThreads(4);
    threadGroup.setRampUp(1);
    threadGroup.setDuration(1);;
    threadGroup.setSamplerController(loopController);
    threadGroup.setSamplerController(PublishController);
    threadGroup.setProperty(TestElement.TEST_CLASS, ThreadGroup.class.getName());
    threadGroup.setProperty(TestElement.GUI_CLASS, ThreadGroupGui.class.getName());

    // Test Plan
    TestPlan testPlan = new TestPlan("IOT_Jmeter");
    testPlan.setProperty(TestElement.TEST_CLASS, TestPlan.class.getName());
    testPlan.setProperty(TestElement.GUI_CLASS, TestPlanGui.class.getName());
    testPlan.setUserDefinedVariables((Arguments) new ArgumentsPanel().createTestElement());

    // HTTP Request Sampler and Header Manager
    HashTree httpRequestTree = new HashTree();
    httpRequestTree.add(mqttConnectSampler);
    httpRequestTree.add(mqttpubSampler);
    httpRequestTree.add(csvDataSet);
    httpRequestTree.add(timer);
因此,无论何时,我都会尝试执行代码。它不会执行

以下是我的eclipse IDE中的日志:

2019-02-12 16:13:28 [main] INFO  StandardJMeterEngine:453 - Starting ThreadGroup: 1 : Thread Group
2019-02-12 16:13:28 [main] INFO  StandardJMeterEngine:513 - Starting 4 threads for group Thread Group.
2019-02-12 16:13:28 [main] INFO  StandardJMeterEngine:523 - Thread will continue on error
2019-02-12 16:13:28 [main] INFO  ThreadGroup:222 - Starting thread group... number=1 threads=4 ramp-up=1 perThread=250.0 delayedStart=false
2019-02-12 16:13:28 [main] INFO  ThreadGroup:236 - Started thread group number 1
2019-02-12 16:13:28 [main] INFO  StandardJMeterEngine:464 - All thread groups have been started
2019-02-12 16:13:28 [Thread Group 1-1] INFO  JMeterThread:705 - Thread started: Thread Group 1-1
2019-02-12 16:13:28 [Thread Group 1-1] INFO  FileServer:265 - Stored: C:\Users\angshuman.basak\Downloads\apache-jmeter-5.0\csvDataNew.csv
2019-02-12 16:13:28 [Thread Group 1-1] INFO  VariableThroughputTimer:304 - No further RPS schedule, asking threads to stop...
2019-02-12 16:13:28 [Thread Group 1-1] INFO  VariableThroughputTimer:319 - Stopping gracefuly threads of Thread Group : Thread Group
2019-02-12 16:13:28 [Thread Group 1-1] INFO  JMeterThread:797 - Stopping: Thread Group 1-2
2019-02-12 16:13:28 [Thread Group 1-1] INFO  JMeterThread:797 - Stopping: Thread Group 1-3
2019-02-12 16:13:28 [Thread Group 1-1] INFO  JMeterThread:797 - Stopping: Thread Group 1-4
2019-02-12 16:13:28 [Thread Group 1-1] INFO  JMeterThread:797 - Stopping: Thread Group 1-1
2019-02-12 16:13:28 [Thread Group 1-1] WARN  VariableThroughputTimer:147 - No free threads available in current Thread Group Thread Group, made 0 samples/s for expected rps 1.0 samples/s, increase your number of threads
2019-02-12 16:13:28 [Thread Group 1-1] INFO  JMeterThread:324 - Thread finished: Thread Group 1-1
2019-02-12 16:13:29 [Thread Group 1-2] INFO  JMeterThread:705 - Thread started: Thread Group 1-2
2019-02-12 16:13:29 [Thread Group 1-2] INFO  JMeterThread:324 - Thread finished: Thread Group 1-2
2019-02-12 16:13:29 [Thread Group 1-3] INFO  JMeterThread:705 - Thread started: Thread Group 1-3
2019-02-12 16:13:29 [Thread Group 1-3] INFO  JMeterThread:324 - Thread finished: Thread Group 1-3
2019-02-12 16:13:29 [Thread Group 1-4] INFO  JMeterThread:705 - Thread started: Thread Group 1-4
2019-02-12 16:13:29 [Thread Group 1-4] INFO  JMeterThread:324 - Thread finished: Thread Group 1-4
2019-02-12 16:13:29 [main] INFO  StandardJMeterEngine:223 - Notifying test listeners of end of test
2019-02-12 16:13:29 [main] INFO  FileServer:485 - Close: C:\Users\angshuman.basak\Downloads\apache-jmeter-5.0\csvDataNew.csv
2019-02-12 16:13:29 [main] INFO  Summariser:327 - summary =      0 in 00:00:00 = ******/s Avg:     0 Min: 9223372036854775807 Max: -9223372036854775808 Err:     0 (0.00%)
summary =      0 in 00:00:00 = ******/s Avg:     0 Min: 9223372036854775807 Max: -9223372036854775808 Err:     0 (0.00%)
上面的摘要表示没有执行测试。从上述日志中,可变吞吐量计时器获取以下信息:

2019-02-12 16:13:28 [Thread Group 1-1] INFO  VariableThroughputTimer:304 - No further RPS schedule, asking threads to stop...
2019-02-12 16:13:28 [Thread Group 1-1] INFO  VariableThroughputTimer:319 - Stopping gracefully threads of Thread Group: Thread Group
2019-02-12 16:13:28 [Thread Group 1-1] WARN  VariableThroughputTimer:147 - No free threads available in current Thread Group Thread Group, made 0 samples/s for expected rps 1.0 samples/s, increase your number of threads
我想用吞吐量成形定时器以编程方式执行代码。如果我的实现不正确或解决了执行问题,我希望为VariableThroughputTimer提供正确的代码


非常感谢您的帮助。

您如何计划仅使用4个线程达到每秒1000个请求?只有当您有4毫秒的响应时间时才有可能,这是极不可能的

根据日志条目,您应该

线程组线程组,为预期的rps 1.0采样/s制作了0个采样/s,增加线程数`

还要确保将底层配置为永远迭代


考虑使用可以与吞吐量整形定时器使用函数连接的JMeter,如果当前的量不足以达到/保持目标吞吐量,那么它将能够启动额外的线程。查看文章了解更多详细信息

您计划如何仅使用4个线程达到每秒1000个请求?只有当您有4毫秒的响应时间时才有可能,这是极不可能的

根据日志条目,您应该

线程组线程组,为预期的rps 1.0采样/s制作了0个采样/s,增加线程数`

还要确保将底层配置为永远迭代


考虑使用可以与吞吐量整形定时器使用函数连接的JMeter,如果当前的量不足以达到/保持目标吞吐量,那么它将能够启动额外的线程。查看文章了解更多详细信息

根据所需的吞吐量,您的线程组配置不合适。由于所需吞吐量为
1000转/秒
,因此如果响应时间为
1秒
,则至少需要
1000个线程
。如果响应时间为
0.5秒
,则需要
500个线程
才能达到
1000转/秒
。因此,仅使用
4个线程
无法实现1000转/秒。您的响应时间必须是
.004秒
(4毫秒),才能仅使用4个线程实现1000转/秒,这是一件不同寻常的事情


您仅将测试持续时间设置为1秒,这在本例中也是错误的。

根据所需的吞吐量,您的线程组配置不合适。由于所需吞吐量为
1000转/秒
,因此如果响应时间为
1秒
,则至少需要
1000个线程
。如果响应时间为
0.5秒
,则需要
500个线程
才能达到
1000转/秒
。因此,仅使用
4个线程
无法实现1000转/秒。您的响应时间必须是
.004秒
(4毫秒),才能仅使用4个线程实现1000转/秒,这是一件不同寻常的事情

您仅将测试持续时间设置为1秒,这在本例中也是错误的