LuaSrcDiet工具介绍(lua源码处理软件)
Diet
Food
- Diet (nutrition), the sum of the food consumed by an organism or group
- Dieting, the deliberate selection of food to control body weight or nutrient intake
- Diet food, foods that aid in creating a diet for weight loss
https://en.wikipedia.org/wiki/Diet
- 节食;进行规定饮食
- n.日常饮食;日常食物;规定饮食(为健康或减肥等目的);规定饮食的时期
- Web食性;食谱;膳食
https://www.bing.com/dict/search?q=diet&FORM=BDVSP2&qpvt=diet
Diet 结合工具的使用, 应该是节食的含义, 即使用规定的饮食,达到减肥的目的。
luaSrcDiet
知道了英文的意思, 这里luasrcdiet == lua source code diet, 即 对lua源代码进行瘦身。
http://luasrcdiet.luaforge.net/
LuaSrcDiet reduces the size of Lua 5.1.x source files by aggressively removing all unnecessary whitespace and comments, optimizing constant tokens, and renaming local variables to shorter names.
LuaSrcDiet squeezes its own (heavily commented) sources from 121KB down to 28KB. Further compression (bzip2 or lzma) brings the size down to under 10KB, representing a 12X reduction in size.
Sample Output
The following is the result of processing llex.lua from LuaSrcDiet 0.11.0
using various optimization options:
| 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:
- Predefined default, --basic
(token-only) and --maximum
settings. - Avoid deleting a block comment with a certain message with --keep; this is for copyright or
license texts. - Special handling for #! (shbang) lines and in functions, "self"
implicit parameters. - Dumping of raw information: lexer
tokens and local variable name
tracking information - Plugin interface (experimental!) with HTML and SLOC plugins.
- HTML plugin: outputs files that highlights globals and locals
(useful for eliminating globals), sample: html_sample.html.
-----
这个挺好@!!!!! - SLOC plugin: counts
significant lines of Lua code, like SLOCCount.
List of optimizations:
- Line endings are always normalized to LF, except those embedded
in comments or strings. - --opt-comments: Removal
of comments and comment blocks. - --opt-whitespace:
Removal of whitespace, excluding end-of-line characters. - --opt-emptylines:
Removal of empty lines. - --opt-eols: Removal of
unnecessary end-of-line characters. - --opt-strings: Rewrite
strings and long strings. Sample: Before and After - --opt-numbers: Rewrite
numbers. Sample: Before and After - --opt-locals: Rename
local variable names. Does not rename field or method names. - --opt-entropy: Tries to
improve symbol entropy when renaming locals by calculating actual
letter frequencies.
与其他工具对比
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.
LuaSrcDiet工具介绍(lua源码处理软件)的更多相关文章
- IPerf——网络测试工具介绍与源码解析(4)
上篇随笔讲到了TCP模式下的客户端,接下来会讲一下TCP模式普通场景下的服务端,说普通场景则是暂时不考虑双向测试的可能,毕竟了解一项东西还是先从简单的情况下入手会快些. 对于服务端,并不是我们认为的直 ...
- IPerf——网络测试工具介绍与源码解析(2)
对于IPerf源码解析,我是基于2.0.5版本在Windows下执行的情况进行分析的,提倡开始先通过对源码的简单修改使其能够在本地编译器运行起来,这样可以打印输出一些中间信息,对于理解源码的逻辑,程序 ...
- IPerf——网络测试工具介绍与源码解析(1)
IPerf是一个开源的测试网络宽带并能统计并报告延迟抖动.数据包丢失率信息的控制台命令程序,通过参数选项可以方便地看出,通过设置不同的选项值对网络带宽的影响,对于学习网络编程还是有一定的借鉴意义,至少 ...
- IPerf——网络测试工具介绍与源码解析(3)
[线程的生成] 生成线程时需要传入一个thread_Settings类型的变量,thread_Settings包含所有线程运行时需要的信息,命令行选项参数解析后所有得到的属性都存储到该类型的变量中 ...
- IPerf——网络测试工具介绍与源码解析(5)
本篇随笔讲述一下TCP协议下,双向测试模式和交易测试模式下客户端和服务端执行的情况: 双向测试模式: 官方文档的解释 Run Iperf in dual testing mode. This will ...
- Lua源码编译之CL编译器编译
通过使用VC下的CL编译器,可方便地编译Lua源码,而无需构造工程并设置各种选项: 以下以源码Lua5.3.1版本为例,将通过CL编译选项直接编译源码,为方便编译将采用批处理脚本,脚本放置在Lua解压 ...
- (转载)Linux如何编译安装源码包软件
一.什么是源码包软件: 顾名思义,源码包就是源代码的可见的软件包,基于Linux和BSD系统的软件最常见:在国内源可见的软件几乎绝迹:大多开源软件都是国外出品:在国内较为出名的开源软件有fcitx;l ...
- 用VC编译lua源码,生成lua语言的解释器和编译器
用VC编译lua源码,生成lua语言的解释器和编译器 1.去网址下载源码 http://www.lua.org/download.html 2.装一个VC++,我用的是VC6.0 3.接下来我们开始编 ...
- 用vs2013编译lua源码方法(一)
用vs2013编译lua源码方法 来源:网络 编辑:admin 1.下载lua源码:lua-5.2.3.tar.gz,解压 2.用vs2013建立一个win32工程: 1)下载后解压到一个目录下 ...
随机推荐
- 前端SEO技巧
前几天在慕课网上学习了“SEO在网页制作中的应用”,觉得挺好.挺有用的,今天,特此做了一个小小的笔记,也算是对学习过后的一个总结. 一.搜索引擎工作原理 当我们在输入框中输入关键词,点击搜索或查询时, ...
- JMeter中BeanShell实现写入文件
1.首先F:\test.txt文件为空
- cookie编码乱码问题与cookie禁用后session操作
Cookie传输的值只能是ASCII码,该编码表相对老旧不含有很多符号与文字 特别是中文,所以在cookie传值过程中需要先转成相应的ASCII编码再解析 如下 URLEncoder.encode(& ...
- Scrum项目8.0
目标:我们开始做每个需要细致的界面,比方说登陆,注册,游戏界面,难度选择 内容:登陆界面:登陆名,登陆密码,登陆按钮,以及优美的底图. 注册页面:名称,密码,登陆按钮,以及优美的底图. 游戏界面:难度 ...
- 【CodeVS2800】 送外卖 最短路+状压DP
首先求出各点之间的最短路,floyed即可,注意是0-n. 然后考虑状压,f[i][j]表示状态为i时访问j点时的最短路和,1表示访问,0表示未访问,然后第j个点所在的位置就是(1<<j) ...
- 推流和拉流的概念以及RTMP和HLS协议
推流为将直播内容推送至服务器的过程:拉流为服务器已有直播内容,用指定地址进行拉取的过程. rtmp rtmp是Real Time Messaging Protocol(实时消息传输协议)的首字母缩写. ...
- 立flag
lixintong这半年来一直浪啊浪啊都不认真做题!!!!!!简直是太堕落啦!!lixintong非常讨厌这样的lixintong !!! 鉴于lixintong NOIP 完全爆炸啦! lixint ...
- Python获取当前日期及时间
import time def GetNowTime(): return time.strftime("%Y%m%d%H%M%S",time.localtime(time.time ...
- c++聪聪看书(低数据版代码)
聪聪是一个善良可爱.睿智聪慧的好孩子.聪聪喜欢看书,这一天她在看一本书时看到了这样一个问题:给你一个正整数n,你要将它分成若干个自然数Ai的和的形式,并且使得这若干个自然数Ai的乘积尽量大,并输出最大 ...
- js日历选择控件
mydate97: http://www.my97.net/dp/demo/index.htm