diff options
Diffstat (limited to 'tests/perftest.lua')
-rw-r--r-- | tests/perftest.lua | 17 |
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 @@ | |||
27 | local MSYS= os.getenv("OSTYPE")=="msys" | 27 | local MSYS= os.getenv("OSTYPE")=="msys" |
28 | 28 | ||
29 | 29 | ||
30 | local lanes = require "lanes" | 30 | local lanes = require "lanes".configure{ with_timers = false} |
31 | lanes.configure() | ||
32 | 31 | ||
33 | local m= require "argtable" | 32 | local m= require "argtable" |
34 | local argtable= assert( m.argtable ) | 33 | local argtable= assert( m.argtable ) |
@@ -36,7 +35,7 @@ local argtable= assert( m.argtable ) | |||
36 | local N= 1000 -- threads/loops to use | 35 | local N= 1000 -- threads/loops to use |
37 | local M= 1000 -- sieves from 1..M | 36 | local M= 1000 -- sieves from 1..M |
38 | local PLAIN= false -- single threaded (true) or using Lanes (false) | 37 | local PLAIN= false -- single threaded (true) or using Lanes (false) |
39 | local SINGLE= false -- cores to use (false / 1..n) | 38 | local SINGLE= 0 -- cores to use (0 / 1..n) |
40 | local TIME= false -- use Lua for the timing | 39 | local TIME= false -- use Lua for the timing |
41 | local PRIO_ODD, PRIO_EVEN -- -3..+3 | 40 | local PRIO_ODD, PRIO_EVEN -- -3..+3 |
42 | 41 | ||
@@ -63,7 +62,7 @@ end | |||
63 | for k,v in pairs( argtable(...) ) do | 62 | for 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 | ||
139 | io.stderr:write( "*** Counting primes 1.."..M.." "..N.." times ***\n\n" ) | 138 | io.stderr:write( "*** Counting primes 1.."..M.." "..N.." times ***\n\n" ) |
140 | 139 | ||
141 | local t0= TIME and os.time() | 140 | local t0= TIME and lanes.now_secs() |
142 | 141 | ||
143 | if PLAIN then | 142 | if 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 |
150 | else | 149 | else |
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 | |||
177 | io.stderr:write "\n" | 176 | io.stderr:write "\n" |
178 | 177 | ||
179 | if TIME then | 178 | if 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" ) |
182 | end | 181 | end |
183 | 182 | ||