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/nat-5.0.3/test/bench_llex_mk2.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 'LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk2.lua')
-rw-r--r-- | LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk2.lua | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk2.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk2.lua deleted file mode 100644 index 873afd1..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk2.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 | |||
15 | local zio_init = require("../lzio_mk2") | ||
16 | local lex_init = require("../llex_mk2") | ||
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 | |||
23 | local fileset, totalsize = {}, 0 | ||
24 | for 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) | ||
33 | end | ||
34 | |||
35 | for 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 | ||
49 | end | ||
50 | |||
51 | ------------------------------------------------------------------------ | ||
52 | -- benchmark tester | ||
53 | ------------------------------------------------------------------------ | ||
54 | |||
55 | local DURATION = 5 -- how long the benchmark should run | ||
56 | |||
57 | local time = os.time | ||
58 | local lexedsize = 0 | ||
59 | local tnow, elapsed = time(), 0 | ||
60 | |||
61 | while time() == tnow do end -- wait for second to click over | ||
62 | tnow = time() | ||
63 | |||
64 | while 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 | ||
92 | end--while | ||
93 | |||
94 | -- end of script | ||