Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/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
使用wrk,将文件作为主体进行HTTP PUT最有效的方法是什么?_Http_Lua_Put_Wrk - Fatal编程技术网

使用wrk,将文件作为主体进行HTTP PUT最有效的方法是什么?

使用wrk,将文件作为主体进行HTTP PUT最有效的方法是什么?,http,lua,put,wrk,Http,Lua,Put,Wrk,我想通过执行许多包含主体文件的HTTP PUT请求来对应用程序进行基准测试。我有很多文件,每个文件只需要发送一次 现在,我正在尝试使用WRK来实现这一点。我发现的一种方法是将我的数据分割成几个repo,给每个WRK线程一个repo。但我的大问题是如何将文件作为PUT参数传递(基本上是执行curl-T)。目前,我正在通过在LUA脚本中重编文件并将内容放入wrk.body中来实现这一点,因为wrk.body的性能不是很好(太慢) 下面是我使用文件参数执行PUT的代码部分: function read

我想通过执行许多包含主体文件的HTTP PUT请求来对应用程序进行基准测试。我有很多文件,每个文件只需要发送一次

现在,我正在尝试使用WRK来实现这一点。我发现的一种方法是将我的数据分割成几个repo,给每个WRK线程一个repo。但我的大问题是如何将文件作为PUT参数传递(基本上是执行curl-T)。目前,我正在通过在LUA脚本中重编文件并将内容放入wrk.body中来实现这一点,因为wrk.body的性能不是很好(太慢)

下面是我使用文件参数执行PUT的代码部分:

function read_file(path)
  local file, errorMessage = io.open(path, "r")
  if not file then 
    error("Could not read the file: "..path.." Error : " .. errorMessage .. "\n")
  end

  local content = file:read "*all"
  file:close()
  return content
end

request = function()
  local body = read_file("/data/"..id.."/"..files[counter])
  counter = counter + 1
  local Boundary = "----WebKitFormBoundaryePkpFF7tjBAqx29L"
  wrk.headers["Content-Type"] = "multipart/form-data; boundary=" .. Boundary

  return wrk.format("PUT", url, wrk.headers,body)
end

我只是想知道是否有更有效的方法使用WRK将文件添加为PUT(或POST)HTTP请求。

请提供一个您尝试过的代码示例。我添加了一些代码示例。我删除了所有用于排列文件名、线程id等列表的代码,但仍然存在一些变量。