<!DOCTYPE html>
<html data-lt-installed="true">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body style="padding-bottom: 1px;">
    <p>on execution I got an error:</p>
    <p>./build/src/luajit: perf/LuaJIT-benches/<a class="moz-txt-link-freetext" href="sum-file.lua:11">sum-file.lua:11</a>: attempt
      to perform arithmetic on local 'line' (a string value)<br>
      <br>
    </p>
    <div class="moz-cite-prefix">On 10/24/25 14:00, Sergey Kaplun wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:5fb7539d5539b29ed416c83a3ec413c5032c99ab.1761301736.git.skaplun@tarantool.org">
      <pre wrap="" class="moz-quote-pre">This patch adjusts the aforementioned test to use the benchmark
framework introduced before. The default arguments are adjusted
according to the <PARAM_x86.txt> file. The arguments to the script still
can be provided in the command line run.

The input for the test is redirected from the generated file
<SUMCOL_5000.txt>. This file is the result of concatenation of the
<SUMCOL_1.txt> 5000 times.
---
 perf/LuaJIT-benches/sum-file.lua | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/perf/LuaJIT-benches/sum-file.lua b/perf/LuaJIT-benches/sum-file.lua
index c9e618fd..270c1865 100644
--- a/perf/LuaJIT-benches/sum-file.lua
+++ b/perf/LuaJIT-benches/sum-file.lua
@@ -1,6 +1,25 @@
+local bench = require("bench").new(arg)
 
-local sum = 0
-for line in io.lines() do
-  sum = sum + line
-end
-io.write(sum, "\n")
+-- XXX: The input file is generated from <SUMCOL_1.txt> by
+-- repeating it 5000 times. The <SUMCOL_1.txt> contains 1000 lines
+-- with the total sum of 500.
+bench:add({
+  name = "sum_file",
+  payload = function()
+    local sum = 0
+    for line in io.lines() do
+      sum = sum + line</pre>
    </blockquote>
    You obviously cannot sum a string and a number.
    <blockquote type="cite"
cite="mid:5fb7539d5539b29ed416c83a3ec413c5032c99ab.1761301736.git.skaplun@tarantool.org">
      <pre wrap="" class="moz-quote-pre">
+    end
+    -- Allow several iterations.
+    <a class="moz-txt-link-freetext" href="io.stdin:seek(">io.stdin:seek(</a>"set", 0)
+    return sum
+  end,
+  checker = function(res)
+    -- Precomputed result.
+    return res == 2500000
+  end,
+  -- Fixed size of the file.
+  items = 5e6,
+})
+
+bench:run_and_report()
</pre>
    </blockquote>
  </body>
  <lt-container></lt-container>
</html>