Permalink
Browse files

Merge #1232 branch 'igalia/fix-lpm-tests' into next

  • Loading branch information...
lukego committed Nov 8, 2017
2 parents cd94e21 + 199c0ce commit e64d1a6532d3c80d62852febf650124887a9cf66
Showing with 51 additions and 22 deletions.
  1. +14 −7 src/lib/lpm/ip4.lua
  2. +8 −1 src/lib/lpm/lpm4.lua
  3. +11 −4 src/lib/lpm/lpm4_poptrie.lua
  4. +18 −10 src/lib/lpm/random.dasl
View
@@ -119,13 +119,20 @@ function IP4.selftest ()
selftest_get_bit()
selftest_commonlength()
local pmu = require("lib.pmu")
local gbit = IP4.get_bit
pmu.profile(function()
local c = 0
for i = 0,1000000 do
c = c + IP4.commonlength(i,i)
end
end)
local avail, err = pmu.is_available()
if not avail then
print("PMU not available:")
print(" "..err)
print("Skipping benchmark.")
else
local gbit = IP4.get_bit
pmu.profile(function()
local c = 0
for i = 0,1000000 do
c = c + IP4.commonlength(i,i)
end
end)
end
end
return IP4
View
@@ -259,6 +259,13 @@ function LPM4:selftest (cfg, millions)
g:verify(f)
C.free(ptr)
self:new(cfg):add_random_entries():benchmark(millions)
local avail, err = require('lib.pmu').is_available()
if not avail then
print("PMU not available:")
print(" "..err)
print("Skipping benchmark.")
else
self:new(cfg):add_random_entries():benchmark(millions)
end
print("selftest complete")
end
@@ -164,10 +164,17 @@ function selftest_get_bits ()
assert(g(p("0.3.128.0"),14) == 56)
assert(g(p("192.0.0.0"),0) == 48)
local pmu = require("lib.pmu")
local n = 0
pmu.profile(function()
for i =0, 1000*1000*1000 do n = n + g(i, 7) end
end)
local avail, err = pmu.is_available()
if not avail then
print("PMU not available:")
print(" "..err)
print("Skipping benchmark.")
else
local n = 0
pmu.profile(function()
for i =0, 1000*1000*1000 do n = n + g(i, 7) end
end)
end
end
function selftest ()
local n = LPM4_poptrie:new()
View
@@ -29,16 +29,24 @@ Rand.u32 = (function()
end)()
function Rand:selftest()
local pmu = require("lib.pmu")
local v = 0
local million = 1000000
local start = C.get_time_ns()
pmu.profile(function()
for i=0, 500*million do
v = Rand.u32(v)
end
end, {}, { random_u32 = 500*million })
print((C.get_time_ns() - start)/(500*million))
local pmu = require("lib.pmu")
local v = 0
local million = 1000000
local function test()
for i=0, 500*million do
v = Rand.u32(v)
end
end
local avail, err = pmu.is_available()
local start = C.get_time_ns()
if not avail then
print("PMU not available:")
print(" "..err)
test()
else
pmu.profile(test, {}, { random_u32 = 500*million })
end
print(tonumber((C.get_time_ns() - start))/(500*million))
end
return Rand

0 comments on commit e64d1a6

Please sign in to comment.