Преглед изворни кода

fx: 测试代码修正

master
SisMaker пре 4 година
родитељ
комит
e08a6b2a5a
3 измењених фајлова са 41 додато и 2 уклоњено
  1. +32
    -0
      README.md
  2. +2
    -2
      src/test/acTc.erl
  3. +7
    -0
      src/test/acTest.erl

+ 32
- 0
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!!!

+ 2
- 2
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]),

+ 7
- 0
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).

Loading…
Откажи
Сачувај