diff options
author | David Walter Seikel | 2014-04-21 20:59:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-04-21 20:59:39 +1000 |
commit | 9621add2918cc4943e6693b74ae85d51dd264fcf (patch) | |
tree | fff1edf2c69d7a08a0e12885eecc9b96ed847a6a /LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/bench_llex.lua | |
parent | LuaSL_test's window doesn't need to be so huge. (diff) | |
download | SledjHamr-9621add2918cc4943e6693b74ae85d51dd264fcf.zip SledjHamr-9621add2918cc4943e6693b74ae85d51dd264fcf.tar.gz SledjHamr-9621add2918cc4943e6693b74ae85d51dd264fcf.tar.bz2 SledjHamr-9621add2918cc4943e6693b74ae85d51dd264fcf.tar.xz |
We don't need the testlua directory any more.
Diffstat (limited to '')
-rw-r--r-- | LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/bench_llex.lua | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/bench_llex.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/bench_llex.lua deleted file mode 100644 index b904470..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/orig-5.1.3/test/bench_llex.lua +++ /dev/null | |||
@@ -1,99 +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 | |||
15 | dofile("../lzio.lua") | ||
16 | dofile("../llex.lua") | ||
17 | luaX:init() | ||
18 | |||
19 | ------------------------------------------------------------------------ | ||
20 | -- load in a standard set of sample files | ||
21 | -- * file set is 5.0.3 front end set sans luac.lua | ||
22 | ------------------------------------------------------------------------ | ||
23 | |||
24 | local fileset, totalsize = {}, 0 | ||
25 | for fn in string.gmatch([[ | ||
26 | ../../orig-5.0.3/lcode.lua | ||
27 | ../../orig-5.0.3/ldump.lua | ||
28 | ../../orig-5.0.3/llex.lua | ||
29 | ../../orig-5.0.3/lopcodes.lua | ||
30 | ../../orig-5.0.3/lparser.lua | ||
31 | ../../orig-5.0.3/lzio.lua | ||
32 | ]], "%S+") do | ||
33 | fileset[#fileset+1] = fn | ||
34 | end | ||
35 | |||
36 | for i = 1, #fileset do | ||
37 | local fn = fileset[i] | ||
38 | local inf = io.open(fn, "rb") | ||
39 | if not inf then | ||
40 | error("failed to open "..fn.." for reading") | ||
41 | end | ||
42 | local data = inf:read("*a") | ||
43 | local data_sz = #data | ||
44 | inf:close() | ||
45 | if not data or data_sz == 0 then | ||
46 | error("failed to read data from "..fn.." or file is zero-length") | ||
47 | end | ||
48 | totalsize = totalsize + data_sz | ||
49 | fileset[i] = data | ||
50 | end | ||
51 | |||
52 | ------------------------------------------------------------------------ | ||
53 | -- benchmark tester | ||
54 | ------------------------------------------------------------------------ | ||
55 | |||
56 | local DURATION = 5 -- how long the benchmark should run | ||
57 | |||
58 | local L = {} -- LuaState | ||
59 | local LS = {} -- LexState | ||
60 | |||
61 | local time = os.time | ||
62 | local lexedsize = 0 | ||
63 | local tnow, elapsed = time(), 0 | ||
64 | |||
65 | while time() == tnow do end -- wait for second to click over | ||
66 | tnow = time() | ||
67 | |||
68 | while true do | ||
69 | for i = 1, #fileset do | ||
70 | ------------------------------------------------------------ | ||
71 | local chunk = fileset[i] | ||
72 | local z = luaZ:init(luaZ:make_getS(chunk), nil) | ||
73 | luaX:setinput(L, LS, z, "=string") | ||
74 | while true do | ||
75 | LS.t.token = luaX:llex(LS, LS.t) | ||
76 | local tok, seminfo = LS.t.token, LS.t.seminfo | ||
77 | if tok == "TK_EOS" then break end | ||
78 | end | ||
79 | ------------------------------------------------------------ | ||
80 | lexedsize = lexedsize + #chunk | ||
81 | if time() > tnow then | ||
82 | tnow = time() | ||
83 | elapsed = elapsed + 1 | ||
84 | if elapsed >= DURATION then | ||
85 | -- report performance of lexer | ||
86 | lexedsize = lexedsize / 1024 | ||
87 | local speed = lexedsize / DURATION | ||
88 | print("Lexer performance:") | ||
89 | print("Size of data lexed (KB): "..string.format("%.1f", lexedsize)) | ||
90 | print("Speed of lexer (KB/s): "..string.format("%.1f", speed)) | ||
91 | -- repeat until user breaks program | ||
92 | elapsed = 0 | ||
93 | end | ||
94 | end | ||
95 | ------------------------------------------------------------ | ||
96 | end--for | ||
97 | end--while | ||
98 | |||
99 | -- end of script | ||