From f2dcd16fc72e2f10c9504897bacf5c4c2ecff516 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 20 Oct 2021 19:36:15 +0800 Subject: +lua libs --- .../Libraries/json4lua/examples/timetrials.lua | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Resources/DefaultContent/Libraries/json4lua/examples/timetrials.lua (limited to 'Resources/DefaultContent/Libraries/json4lua/examples/timetrials.lua') diff --git a/Resources/DefaultContent/Libraries/json4lua/examples/timetrials.lua b/Resources/DefaultContent/Libraries/json4lua/examples/timetrials.lua new file mode 100644 index 0000000..cbda514 --- /dev/null +++ b/Resources/DefaultContent/Libraries/json4lua/examples/timetrials.lua @@ -0,0 +1,46 @@ +--[[ + Some Time Trails for the JSON4Lua package +]]-- + + +require('json') +require('os') +require('table') + +local t1 = os.clock() +local jstr +local v +for i=1,100 do + local t = {} + for j=1,500 do + table.insert(t,j) + end + for j=1,500 do + table.insert(t,"VALUE") + end + jstr = json.encode(t) + v = json.decode(jstr) + --print(json.encode(t)) +end + +for i = 1,100 do + local t = {} + for j=1,500 do + local m= math.mod(j,3) + if (m==0) then + t['a'..j] = true + elseif m==1 then + t['a'..j] = json.null + else + t['a'..j] = j + end + end + jstr = json.encode(t) + v = json.decode(jstr) +end + +print (jstr) +--print(type(t1)) +local t2 = os.clock() + +print ("Elapsed time=" .. os.difftime(t2,t1) .. "s") \ No newline at end of file -- cgit v1.1-26-g67d0