aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk4.lua
diff options
context:
space:
mode:
Diffstat (limited to 'LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk4.lua')
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk4.lua94
1 files changed, 0 insertions, 94 deletions
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk4.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk4.lua
deleted file mode 100644
index b94386b..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk4.lua
+++ /dev/null
@@ -1,94 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 bench_llex.lua
4 Benchmark test for llex.lua
5 This file is part of Yueliang.
6
7 Copyright (c) 2006 Kein-Hong Man <khman@users.sf.net>
8 The COPYRIGHT file describes the conditions
9 under which this software may be distributed.
10
11 See the ChangeLog for more information.
12
13----------------------------------------------------------------------]]
14
15local zio_init = require("../lzio_mk4")
16local lex_init = require("../llex_mk4")
17
18------------------------------------------------------------------------
19-- load in a standard set of sample files
20-- * file set is 5.0.3 front end set sans luac.lua
21------------------------------------------------------------------------
22
23local fileset, totalsize = {}, 0
24for fn in string.gfind([[
25../../orig-5.0.3/lcode.lua
26../../orig-5.0.3/ldump.lua
27../../orig-5.0.3/llex.lua
28../../orig-5.0.3/lopcodes.lua
29../../orig-5.0.3/lparser.lua
30../../orig-5.0.3/lzio.lua
31]], "%S+") do
32 table.insert(fileset, fn)
33end
34
35for i = 1, table.getn(fileset) do
36 local fn = fileset[i]
37 local inf = io.open(fn, "rb")
38 if not inf then
39 error("failed to open "..fn.." for reading")
40 end
41 local data = inf:read("*a")
42 local data_sz = string.len(data)
43 inf:close()
44 if not data or data_sz == 0 then
45 error("failed to read data from "..fn.." or file is zero-length")
46 end
47 totalsize = totalsize + data_sz
48 fileset[i] = data
49end
50
51------------------------------------------------------------------------
52-- benchmark tester
53------------------------------------------------------------------------
54
55local DURATION = 5 -- how long the benchmark should run
56
57local time = os.time
58local lexedsize = 0
59local tnow, elapsed = time(), 0
60
61while time() == tnow do end -- wait for second to click over
62tnow = time()
63
64while true do
65 for i = 1, table.getn(fileset) do
66 ------------------------------------------------------------
67 local chunk = fileset[i]
68 local z = zio_init(chunk)
69 local luaX = lex_init(z, "=string")
70 while true do
71 local tok, seminfo = luaX:lex()
72 if tok == "<eof>" then break end
73 end
74 ------------------------------------------------------------
75 lexedsize = lexedsize + string.len(chunk)
76 if time() > tnow then
77 tnow = time()
78 elapsed = elapsed + 1
79 if elapsed >= DURATION then
80 -- report performance of lexer
81 lexedsize = lexedsize / 1024
82 local speed = lexedsize / DURATION
83 print("Lexer performance:")
84 print("Size of data lexed (KB): "..string.format("%.1f", lexedsize))
85 print("Speed of lexer (KB/s): "..string.format("%.1f", speed))
86 -- repeat until user breaks program
87 elapsed = 0
88 end
89 end
90 ------------------------------------------------------------
91 end--for
92end--while
93
94-- end of script