]> source.dussan.org Git - rspamd.git/commitdiff
Corpus test improvements
authorSteve Freegard <steve@stevefreegard.com>
Mon, 19 Mar 2018 12:11:24 +0000 (12:11 +0000)
committerSteve Freegard <steve@stevefreegard.com>
Mon, 19 Mar 2018 12:11:24 +0000 (12:11 +0000)
lualib/rspamadm/corpus_test.lua

index eb93d586c681635c15a289c03d5057cfe9222b89..b71f96e9eec93c8d8dff3ad4508eb7e5a2236e84 100644 (file)
@@ -5,10 +5,10 @@ local lua_util = require "lua_util"
 local HAM = "HAM"
 local SPAM = "SPAM"
 
-local function scan_email(n_parellel, path, timeout)
+local function scan_email(n_parallel, path, timeout)
 
     local rspamc_command = string.format("rspamc -j --compact -n %s -t %.3f %s",
-        n_parellel, timeout, path)
+        n_parallel, timeout, path)
     local result = assert(io.popen(rspamc_command))
     result = result:read("*all")
     return result
@@ -25,6 +25,8 @@ local function write_results(results, file)
             log_line = log_line .. " " .. sym
         end
 
+        log_line = log_line .. " " .. result.scan_time .. " " .. file .. ':' .. result.filename
+
         log_line = log_line .. "\r\n"
 
         f:write(log_line)
@@ -62,6 +64,9 @@ local function encoded_json_to_log(result)
         table.insert(filtered_result.symbols, sym)
     end
 
+    filtered_result.filename = result.filename
+    filtered_result.scan_time = result.scan_time
+
     return filtered_result   
 end
 
@@ -127,8 +132,10 @@ return function (_, res)
     write_results(results, output)
 
     io.write("\nStats: \n")
+    local elapsed_time = os.time() - start_time
+    local total_msgs = no_of_ham + no_of_spam
     io.write(string.format("Elapsed time: %ds\n", os.time() - start_time))
     io.write(string.format("No of ham: %d\n", no_of_ham))
     io.write(string.format("No of spam: %d\n", no_of_spam))
-
+    io.write(string.format("Messages/sec: %-.2f\n", (total_msgs/elapsed_time)))
 end