diff options
| author | ruki <[email protected]> | 2020-03-01 21:36:23 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-03-01 21:36:23 +0800 |
| commit | c68fa66a89dcce3bf589703435c01e7aa8b2ef2b (patch) | |
| tree | de78dc4394ffaf598cdfb4fb5be038f41c9d9d81 | |
| parent | a64a335f331fd34d082f0c17f6d81012976fe748 (diff) | |
add split_perf test
| -rw-r--r-- | tests/modules/string/split_perf.lua | 37 | ||||
| -rw-r--r-- | xmake/modules/private/tools/gcc/parse_deps.lua | 2 |
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/modules/string/split_perf.lua b/tests/modules/string/split_perf.lua new file mode 100644 index 000000000..96d62dad9 --- /dev/null +++ b/tests/modules/string/split_perf.lua @@ -0,0 +1,37 @@ + +function _split_perf(str, pattern, opt) + local dt = os.mclock() + for i = 0, 1000000 do + str:split(pattern, opt) + end + dt = os.mclock() - dt + print("split(%s .., %s, %s): %d ms", str:sub(1, 16), pattern, string.serialize(opt or {}, {strip = true, indent = false}), dt) +end + +function main() + + local str = "shortstr: 123abc123123xyz[123]+abc123" + _split_perf(str, "1") + _split_perf(str, "123") + _split_perf(str, "[123]+") + print("") + + _split_perf(str, "1", {plain = true}) + _split_perf(str, "123", {plain = true}) + _split_perf(str, "[123]+", {plain = true}) + print("") + + str = "longstr: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + for i = 0, 100 do + str = str .. "123yy[123]+" + end + _split_perf(str, "1") + _split_perf(str, "123") + _split_perf(str, "[123]+") + print("") + + _split_perf(str, "1", {plain = true}) + _split_perf(str, "123", {plain = true}) + _split_perf(str, "[123]+", {plain = true}) + print("") +end diff --git a/xmake/modules/private/tools/gcc/parse_deps.lua b/xmake/modules/private/tools/gcc/parse_deps.lua index 19ae51cbf..4c672d599 100644 --- a/xmake/modules/private/tools/gcc/parse_deps.lua +++ b/xmake/modules/private/tools/gcc/parse_deps.lua @@ -46,6 +46,8 @@ end -- parse depsfiles from string -- +-- parse_deps(io.readfile(depfile, {continuation = "\\"})) +-- -- eg. -- strcpy.o: src/tbox/libc/string/strcpy.c src/tbox/libc/string/string.h \ -- src/tbox/libc/string/prefix.h src/tbox/libc/string/../prefix.h \ |
