比较Macbook Air上的这个Lua Script的执行时间(Mac OS 10.9.4,i5-4250U(1.3GHz),8GB RAM)到运行Arch Linux的VM(虚拟机).
首先,我使用clang编译lua,将其与Mac OS X clang二进制文件进行比较.
$ tcc *[^ca].c lgc.c lfunc.c lua.c -lm -o luatcc
$ gcc -O3 *[^ca].c lgc.c lfunc.c lua.c -lm -o luagcc
/tmp/ccxAEYH8.o: In function `os_tmpname':
loslib.c:(.text+0x29c): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
$ clang -O3 *[^ca].c lgc.c lfunc.c lua.c -lm -o luaclang
/tmp/loslib-bd4ef4.o:loslib.c:function os_tmpname: warning: the use of `tmpnam' is dangerous, better use `mkstemp'
Run Code Online (Sandbox Code Playgroud)
VM中的clang版本
$ clang --version
clang version 3.4.2 …Run Code Online (Sandbox Code Playgroud) 我有一个压缩的gzip文件,我想逐行阅读.
var fs = require('fs')
var zlib = require('zlib')
var gunzip = zlib.createGunzip()
var inp = fs.createReadStream('test.gz')
var n = 0
var lineProcessing = function (err, data) {
if (!err) {
n += 1
console.log ("line: " + n)
console.log (data.toString())
}
}
inp
.on('data', function (chunk) {
zlib.gunzip (chunk, lineProcessing)
})
.on('end', function () {
console.log ('ende');
});
Run Code Online (Sandbox Code Playgroud)
我想我需要设置一个chunksize zlib.createGunzip,我只读到下一个\n.但如何动态确定呢?
我有一个像这样的对象的json列表
[{
"something": "bla",
"id": 2
}, {
"something": "yes",
"id": 1
}]
Run Code Online (Sandbox Code Playgroud)
我的id字段始终是一个数值。但是当我尝试查找时id = 2,MySQL返回NULL
select
json_search(
json_extract(
'[{"something": "bla" ,"id": 2}, {"something": "yes","id": 1}]',
"$[*].id"
),
'one',
2
) as json_search;
json_search |
------------|
|
Run Code Online (Sandbox Code Playgroud)
当我在我的json id对象中使用字符串作为值而不是数字值时,得到的结果为索引0。
select
json_search(
json_extract(
'[{"something": "bla" ,"id": "2"}, {"something": "yes","id": 1}]',
"$[*].id"
),
'one',
"2"
) as json_search;
json_search |
------------|
"$[0]" |
Run Code Online (Sandbox Code Playgroud)
我正在使用MySQL 5.7.17
@@version |
-----------|
5.7.17-log |
Run Code Online (Sandbox Code Playgroud)
MySQL不提供json数组中的数字搜索吗?