aboutsummaryrefslogtreecommitdiff
path: root/tests/perftest.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/perftest.lua')
-rw-r--r--tests/perftest.lua17
1 files changed, 8 insertions, 9 deletions
diff --git a/tests/perftest.lua b/tests/perftest.lua
index 4df2ad8..6ffc064 100644
--- a/tests/perftest.lua
+++ b/tests/perftest.lua
@@ -27,8 +27,7 @@
27local MSYS= os.getenv("OSTYPE")=="msys" 27local MSYS= os.getenv("OSTYPE")=="msys"
28 28
29 29
30local lanes = require "lanes" 30local lanes = require "lanes".configure{ with_timers = false}
31lanes.configure()
32 31
33local m= require "argtable" 32local m= require "argtable"
34local argtable= assert( m.argtable ) 33local argtable= assert( m.argtable )
@@ -36,7 +35,7 @@ local argtable= assert( m.argtable )
36local N= 1000 -- threads/loops to use 35local N= 1000 -- threads/loops to use
37local M= 1000 -- sieves from 1..M 36local M= 1000 -- sieves from 1..M
38local PLAIN= false -- single threaded (true) or using Lanes (false) 37local PLAIN= false -- single threaded (true) or using Lanes (false)
39local SINGLE= false -- cores to use (false / 1..n) 38local SINGLE= 0 -- cores to use (0 / 1..n)
40local TIME= false -- use Lua for the timing 39local TIME= false -- use Lua for the timing
41local PRIO_ODD, PRIO_EVEN -- -3..+3 40local PRIO_ODD, PRIO_EVEN -- -3..+3
42 41
@@ -63,7 +62,7 @@ end
63for k,v in pairs( argtable(...) ) do 62for k,v in pairs( argtable(...) ) do
64 if k==1 then N= tonumber(v) or HELP() 63 if k==1 then N= tonumber(v) or HELP()
65 elseif k=="plain" then PLAIN= true 64 elseif k=="plain" then PLAIN= true
66 elseif k=="single" then SINGLE= v -- true/number 65 elseif k=="single" then SINGLE= v -- number
67 elseif k=="time" then TIME= true 66 elseif k=="time" then TIME= true
68 elseif k=="prio" then PRIO_ODD, PRIO_EVEN= prio_param(v) 67 elseif k=="prio" then PRIO_ODD, PRIO_EVEN= prio_param(v)
69 else HELP() 68 else HELP()
@@ -104,7 +103,7 @@ local function sieve_lane(N,id)
104 while 1 do 103 while 1 do
105 local n = g() 104 local n = g()
106 if n == nil then return end 105 if n == nil then return end
107 if math.mod(n, p) ~= 0 then coroutine.yield(n) end 106 if math.fmod(n, p) ~= 0 then coroutine.yield(n) end
108 end 107 end
109 end) 108 end)
110 end 109 end
@@ -138,7 +137,7 @@ local f_odd= lanes.gen( "base,coroutine,math,table,io", -- "*" = all
138 137
139io.stderr:write( "*** Counting primes 1.."..M.." "..N.." times ***\n\n" ) 138io.stderr:write( "*** Counting primes 1.."..M.." "..N.." times ***\n\n" )
140 139
141local t0= TIME and os.time() 140local t0= TIME and lanes.now_secs()
142 141
143if PLAIN then 142if PLAIN then
144 io.stderr:write( "Plain (no multithreading):\n" ) 143 io.stderr:write( "Plain (no multithreading):\n" )
@@ -148,9 +147,9 @@ if PLAIN then
148 assert( type(tmp)=="table" and tmp[1]==2 and tmp[168]==997 ) 147 assert( type(tmp)=="table" and tmp[1]==2 and tmp[168]==997 )
149 end 148 end
150else 149else
151 if SINGLE then 150 if SINGLE > 0 then
152 io.stderr:write( (tonumber(SINGLE) and SINGLE or 1) .. " core(s):\n" ) 151 io.stderr:write( (tonumber(SINGLE) and SINGLE or 1) .. " core(s):\n" )
153 lanes.single(SINGLE) -- limit to N cores (just OS X) 152 lanes.set_singlethreaded(SINGLE) -- limit to N cores (just OS X)
154 else 153 else
155 io.stderr:write( "Multi core:\n" ) 154 io.stderr:write( "Multi core:\n" )
156 end 155 end
@@ -177,7 +176,7 @@ end
177io.stderr:write "\n" 176io.stderr:write "\n"
178 177
179if TIME then 178if TIME then
180 local t= os.time() - t0 179 local t= lanes.now_secs() - t0
181 io.stderr:write( "*** TIMING: "..t.." seconds ***\n" ) 180 io.stderr:write( "*** TIMING: "..t.." seconds ***\n" )
182end 181end
183 182