mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 16:09:32 +00:00
43 lines
688 B
Lua
43 lines
688 B
Lua
--
|
|
-- (C) 2018 - ntop.org
|
|
--
|
|
|
|
local test_utils = {}
|
|
|
|
-- ##############################################
|
|
|
|
function test_utils.makeTimeStamp(series, tstart, tstep)
|
|
local v = {}
|
|
|
|
for idx, serie in ipairs(series) do
|
|
local data = {}
|
|
t = tstart
|
|
|
|
for i, pt in ipairs(serie.data) do
|
|
data[i] = {t, pt}
|
|
t = t + tstep
|
|
end
|
|
|
|
v[idx] = data
|
|
end
|
|
|
|
return v
|
|
end
|
|
|
|
-- ##############################################
|
|
|
|
function test_utils.timestampAsKey(tstamped_series)
|
|
local rv = {}
|
|
|
|
for idx, serie in pairs(tstamped_series) do
|
|
rv[idx] = {}
|
|
|
|
for _, val in ipairs(serie) do
|
|
rv[idx][val[1]] = val[2]
|
|
end
|
|
end
|
|
|
|
return rv
|
|
end
|
|
|
|
return test_utils
|