如何在jmeter中写入csv${{{uuuu threadNum}${{uuu time(ddMMyyyy,)}${{uu BeanShell(vars.getIteration();,)}?

如何在jmeter中写入csv${{{uuuu threadNum}${{uuu time(ddMMyyyy,)}${{uu BeanShell(vars.getIteration();,)}?,jmeter,jmeter-plugins,jmeter-5.0,Jmeter,Jmeter Plugins,Jmeter 5.0,我通过${{uuuuThreadNum}${{uuuuTime(ddMMyyyy,)}${{uuuuuBeanshell(vars.getIteration();,)}的组合生成一些唯一的数字 现在我想在csv或jmeter中写入相同的数字。 我正在为此使用bean shell后处理器。使用以下代码:- int random_var = ${__threadNum}${__time(ddMMyyyy,)}${__BeanShell(vars.getIteration();,)}; f = new

我通过${{uuuuThreadNum}${{uuuuTime(ddMMyyyy,)}${{uuuuuBeanshell(vars.getIteration();,)}的组合生成一些唯一的数字 现在我想在csv或jmeter中写入相同的数字。 我正在为此使用bean shell后处理器。

使用以下代码:-

int random_var = ${__threadNum}${__time(ddMMyyyy,)}${__BeanShell(vars.getIteration();,)};
f = new FileOutputStream("D:/Output1.csv", true);
p = new PrintStream(f); 
this.interpreter.setOut(p); 
print(random_var);
f.flush();
f.close();

有多种方法,但上面只是一个例子。为了提高性能,建议使用groovy。 其他帮助文章:-https://www.blazemeter.com/blog/saving-data-to-csv-files-with-java-through-jmeter 对于groovy检查:-https://stackoverflow.com/questions/51597623/jmeter-jsr223-sampler-unable-to-write-data-to-csv-file

  • 假设以上几点是相关的Groovy代码

    def first = ctx.getThreadNum()
    def second = new java.text.SimpleDateFormat('ddMMyyyy').format(new Date())
    def third = vars.getIteration()
    
    new File('myFile.txt') << first << second << third
    
    def first=ctx.getThreadNum()
    def second=new java.text.simpleDataFormat('ddMMyyyy').format(new Date())
    def third=vars.getIteration()
    新文件('myFile.txt')