summaryrefslogtreecommitdiffstats
path: root/contrib/benchmarks/lxsc/statesPerSecond.lua
blob: 8469ea50fe5777bf773fe48a3c2eeb43564977c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env lua

package.path = 'LXSC/?.lua;' .. package.path

require 'io'
require 'os'
local LXSC = require 'lxsc'
local file = ...
local init, mark, now
local iterations = 0

local started = os.clock()
local xml = io.open(file):read("*all")
lxsc = LXSC:parse(xml)

lxsc.onAfterEnter = function(id,kind) 
	if (id=="mark") then
		iterations = iterations + 1
		now = os.clock()
		if (now - mark > 1) then
			print(init .. ", " .. iterations)
			mark = now
			iterations = 0
		end
	end
end

now = os.clock()
init = (now - started) * 1000;
mark = now

lxsc:start()