I've been coding GLua for 4 years, i started making my first Love2D project 1.5 month ago.
Here is the problem :
The game i'm working on use saves ... big saves (300kb-600kb), and the JSON lib i found is sslloooowwwwww as hell.
I tried about 4 JSON libs, all of them takes about 7 secs to load a 300kb file.
Here is the save http://puu.sh/gHZXA/5b409c692b.txt
And here is the code writing the save and deploying the save (merging with _G )
Code: Select all
function do_save_data()
local tbl = {}
local str;
tbl.T_DAY = T_DAY
tbl.T_SEM = T_SEM
tbl.T_MONTH = T_MONTH
tbl.T_YEAR = T_YEAR
tbl.annualPayment = annualPayment
tbl.Passed3mLimit = Passed3mLimit
tbl.Money = Money
tbl.Pub = Pub
tbl.PassedEvents = PassedEvents
tbl.DynaEvent = DynaEvent
tbl.nbEmployees = nbEmployees
tbl.nbInvestisseurs = nbInvestisseurs
--tbl.tabInvestisseurs = tabInvestisseurs
tbl.Popularity = Popularity
tbl.Salary = Salary
tbl.mainRate = mainRate
tbl.Popularity = Popularity
tbl.nbClients = nbClients
tbl.PastMonthEvent = PastMonthEvent
tbl.minimalInvestment = minimalInvestment
tbl.middle1Investment = middle1Investment
tbl.middle2Investment = middle2Investment
tbl.maximalInvestment = maximalInvestment
tbl.minimalTimeInvestment = minimalTimeInvestment
tbl.middle1TimeInvestment = middle1TimeInvestment
tbl.middle2TimeInvestment = middle2TimeInvestment
tbl.maximalTimeInvestment = maximalTimeInvestment
tbl.minimalRendement = minimalRendement
tbl.middleRendement = middleRendement
tbl.maximalRendement = maximalRendement
tbl.minimal2Rendement = minimal2Rendement
tbl.middle2Rendement = middle2Rendement
tbl.maximal2Rendement = maximal2Rendement
str = json.encode(tbl)
love.filesystem.write("data.txt", str)
end
function do_restore()
local str = love.filesystem.read("data.txt")
local tbl = json.decode(str)
table.Merge(_G, tbl)
hook.Call("SaveRestored")
end
Here is the project ran under a profiler
I'm using JSON4LUA, available here -> https://github.com/craigmj/json4lua/blo ... n/json.lua
So what can i do ? Use CJSON ? (How can i find a precompiled lib, there is no doc about the vitual func if we wanna build a lib)
Compress the data before ? (how ?)
Regards,
-Lapin