在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
https://en.wikipedia.org/wiki/Diet
https://www.bing.com/dict/search?q=diet&FORM=BDVSP2&qpvt=diet
Diet 结合工具的使用, 应该是节食的含义, 即使用规定的饮食,达到减肥的目的。 luaSrcDiet知道了英文的意思, 这里luasrcdiet == lua source code diet, 即 对lua源代码进行瘦身。
http://luasrcdiet.luaforge.net/
Sample Output
|
LuaSrcDiet
Option |
Size (bytes) |
Link to
Sample File |
Original |
12,421 |
llex.lua.txt |
Empty lines only |
12,395 |
llex_emptylines.lua.txt |
Whitespace only |
9,372 |
llex_whitespace.lua.txt |
Local rename only |
11,794 |
llex_locals.lua.txt |
--basic
(token optimizations only) |
3,835 |
llex_basic.lua.txt |
Program default |
3,208 |
llex_default.lua.txt |
--maximum |
3,130 |
llex_maximum.lua.txt |
LuaSrcDiet features include the following:
List of optimizations:
File sizes of LuaSrcDiet 0.11.0 main files in various forms:
Source File |
Original Size (bytes) |
luac normal (bytes) |
luac stripped (bytes) |
LuaSrcDiet --basic (bytes) |
LuaSrcDiet --maximum (bytes) |
LuaSrcDiet.lua
|
21,961 |
20,952 |
11,000 |
11,005 |
8,159 |
llex.lua |
12,421 |
8,613 |
4,247 |
3,835 |
3,130 |
lparser.lua |
41,757 |
27,215 |
12,506 |
11,755 |
7,666 |
optlex.lua |
31,009 |
16,992 |
8,021 |
9,129 |
6,858 |
optparser.lua |
16,511 |
9,021 |
3,520 |
5,087 |
2,999 |
Total |
123,659 |
82,793 |
39,294 |
40,811 |
28,812 |
Null loop |
Stripped binary chunk |
Original Sources |
Squeezed Sources |
||
Total Size |
(bytes) |
0 |
39,294 |
123,640 |
28,793 |
Iterations |
312,155 |
9,680 |
1306 |
1,592 |
|
Duration |
(sec) |
10 |
10 |
10 |
10 |
Time/iteration |
(msec) |
0.032 |
1.033 |
7.657 |
6.281 |
Time/iteration,
adjusted for null |
(msec) |
- |
1.001 |
7.625 |
6.249 |
Load rate |
(MB/sec) |
- |
37.44 |
15.46 |
4.39 |
Load time per byte |
(ns) |
- |
25.5 |
61.7 |
217.0 |
Load time per token | (ns) |
- |
- |
682 |
559 |
Source time vs binary chunk time
ratio |
- |
1.00 |
7.62 |
6.24 |
|
Binary chunk rate vs. source rate ratio | - |
1.00 |
2.42 |
8.53 |
The LuaSrcDiet 0.11.0 files (original, squeezed with --maximum and stripped binary chunks versions) are loaded into memory first before a loop runs to repeatedly load the script files for 10 seconds. A null loop is also performed (processing empty strings) and the time taken per null iteration is subtracted as a form of null adjustment. Then, various performance parameters are calculated. Note that LuaSrcDiet.lua was slightly modified (#! line removed) to let the loadstring function run. The results below were obtained with a Lua 5.1.3 executable compiled using "make generic" on Cygwin/Windows XP SP2 on a Sempron 3000+ (1.8GHz). The LuaSrcDiet 0.11.0 source files have 11,180 'real' tokens in total.
Null loop |
Stripped binary chunk |
Original Sources |
Squeezed Sources |
||
Total Size |
(bytes) |
0 |
39,294 |
123,640 |
28,793 |
Iterations |
312,155 |
9,680 |
1306 |
1,592 |
|
Duration |
(sec) |
10 |
10 |
10 |
10 |
Time/iteration |
(msec) |
0.032 |
1.033 |
7.657 |
6.281 |
Time/iteration,
adjusted for null |
(msec) |
- |
1.001 |
7.625 |
6.249 |
Load rate |
(MB/sec) |
- |
37.44 |
15.46 |
4.39 |
Load time per byte |
(ns) |
- |
25.5 |
61.7 |
217.0 |
Load time per token | (ns) |
- |
- |
682 |
559 |
Source time vs binary chunk time
ratio |
- |
1.00 |
7.62 |
6.24 |
|
Binary chunk rate vs. source rate ratio | - |
1.00 |
2.42 |
8.53 |
The above shows that stripped binary chunks is still, in many ways, the highest-performance form of fixed Lua scripts. On a very average machine, scripts load at over 37MB/sec (in memory). This is very comparable to the burst speeds of common desktop hard disks of 2008. If instant response is paramount, stripped binary chunks has little competition.
请发表评论