示例工程 24-performance

24-performance/01-concat-vs-tableconcat/README.md

markdown · 0.6 KB

# 01 · concat-vs-tableconcat
 
**演示**:1 万段 `..` 与 `table.concat` 的 `os.clock` 对比。
**运行时**:`lua54`、`luajit`。
**运行**:
 
```sh
.tools/bin/lua54 scripts/run-example.lua examples/24-performance/01-concat-vs-tableconcat
.tools/bin/lua54 scripts/test-example.lua examples/24-performance/01-concat-vs-tableconcat
```
 
**预期输出**(lua 5.4.9 / macOS arm64;耗时随机器变化):
 
```text
join_faster=true same_length=true
```
 
**看点**:`..` 是 O(n²),`table.concat` 一次分配。
**注意**:只断言量级,不写死毫秒。