diff --git a/README.md b/README.md index 3135e7d..bcc0754 100644 --- a/README.md +++ b/README.md @@ -17,4 +17,36 @@ Uses eAcs:isHasSw/1 %% 检查是否包含敏感词 eAcs:replaceSw/1 %% 替换敏感词 +性能 +----- + 实际测试中 + 基于在一个2万敏感词构造的ac状态树中测试 匹配耗时为 50-100ns 一个字 算下来1秒可以匹配上千万的文本 + 测试示例(测试前先注释掉测试代码打印的参数和eAcs matchSw匹配输出的列表构造): + 下载了一个比较火的动漫小说 吞噬星空.txt + 查看该小说有多少字 + {ok, DataStr} = file:read_file("吞噬星空.txt"), + eAcs:strSize(DataStr, 0). -> 5729268 + 测试匹配 + acTest:test4(100, "./src/test/tttt.txt"). + ===================== + execute Fun :matchSw + execute Mod :eAcs + execute LoopTime:100 + MaxTime: 450278766(ns) 0.450279(s) + MinTime: 428782619(ns) 0.428783(s) + SumTime: 4345761036(ns) 43.45761(s) + AvgTime: 434576103.(ns) 0.434576(s) + Grar : 43(cn) 0.43(%) + Less : 57(cn) 0.57(%) + ===================== + ok + + It's really fast!!! + + + + + + + diff --git a/src/test/acTc.erl b/src/test/acTc.erl index 60c805a..c761df8 100644 --- a/src/test/acTc.erl +++ b/src/test/acTc.erl @@ -99,7 +99,7 @@ distribution([], _Aver, Greater, Less) -> ts(LoopTime, M, F, A) -> {Max, Min, Sum, Aver, Greater, Less} = loopTs(LoopTime, M, F, A, LoopTime, 0, 0, 0, []), io:format("=====================~n"), - io:format("execute Args:~p~n", [A]), + %io:format("execute Args:~p~n", [A]), io:format("execute Fun :~p~n", [F]), io:format("execute Mod :~p~n", [M]), io:format("execute LoopTime:~p~n", [LoopTime]), @@ -143,7 +143,7 @@ tm(ProcCnt, LoopTime, M, F, A) -> loopSpawn(ProcCnt, M, F, A, self(), LoopTime), {Max, Min, Sum, Aver, Greater, Less} = collector(ProcCnt, 0, 0, 0, ProcCnt, []), io:format("=====================~n"), - io:format("execute Args:~p~n", [A]), + %io:format("execute Args:~p~n", [A]), io:format("execute Fun :~p~n", [F]), io:format("execute Mod :~p~n", [M]), io:format("execute LoopTime:~p~n", [LoopTime]), diff --git a/src/test/acTest.erl b/src/test/acTest.erl index fc25d65..72f468f 100644 --- a/src/test/acTest.erl +++ b/src/test/acTest.erl @@ -9,3 +9,10 @@ test1() -> test2() -> acTc:ts(1000000, eAcs, matchSw, [<<"fdsfads拉法叶舰fds淫秽ffdsfdsffdddd"/utf8>>]). + +test3(Cnt, BinStr) -> + acTc:ts(Cnt, eAcs, matchSw, [BinStr]). + +test4(Cnt, FileName) -> + {ok, Data} = file:read_file(FileName), + test3(Cnt, Data). \ No newline at end of file