gpt4 book ai didi

testing - JMeter 使随机数返回 float

转载 作者:行者123 更新时间:2023-11-28 20:04:43 24 4
gpt4 key购买 nike

我有这个:

  "latitude": ${__Random(-85,85)},
"longitude": ${__Random(-180,180)},

我想要这个:

  "latitude": ${__Random(42.06,42.08)},
"longitude": ${__Random(20.02,20.04)},

但它不起作用。如何将其更改为具有介于 42.06 - 42.08 和 20.02 和 20.04 之间的随机数?

最佳答案

如果您需要有限的随机值,只需使用 20.0 之类的静态前缀并调用 __Random()生成后缀的函数,例如:

"latitude": 42.0${__Random(6,8,)},
"longitude": 20.0${__Random(2,4,)},

如果您正在寻找一种方法来生成完全随机的纬度和经度值,我建议您切换到 __javaScript()功能如:

"latitude": ${__javaScript((Math.random() * (180) - 90).toFixed(2) * 1,)},
"longitude": ${__javaScript((Math.random() * (360) - 180).toFixed(2) * 1,)},

参见 How to Use JMeter Functions有关上述和其他 JMeter 函数的更多信息,请发布系列文章。

关于testing - JMeter 使随机数返回 float ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38724673/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com