|
|
@ -6,6 +6,7 @@ |
|
|
|
, update = [] |
|
|
|
, for = [] |
|
|
|
, delete = [] |
|
|
|
, size = [] |
|
|
|
}). |
|
|
|
|
|
|
|
%-define(V_NUM, [8, 16, 32, 64, 128, 256, 516, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 524288, 1048576]). |
|
|
@ -48,16 +49,16 @@ runCnt(Cnt, Num, Ds) -> |
|
|
|
runExe(Num, Ds) -> |
|
|
|
Pid = erlang:spawn_link(Ds, start, [Num, self()]), |
|
|
|
receive |
|
|
|
{over, Pid, InsertTU, ReadTU, UpdateTU, ForTU, DeleteTU} -> |
|
|
|
{over, Pid, InsertTU, ReadTU, UpdateTU, ForTU, DeleteTU, TermSize} -> |
|
|
|
Insert = cvrTUnit(InsertTU), |
|
|
|
Read = cvrTUnit(ReadTU), |
|
|
|
Update = cvrTUnit(UpdateTU), |
|
|
|
For = cvrTUnit(ForTU), |
|
|
|
Delete = cvrTUnit(DeleteTU), |
|
|
|
storeStatistics(Ds, Num, Insert, Read, Update, For, Delete), |
|
|
|
storeStatistics(Ds, Num, Insert, Read, Update, For, Delete, TermSize), |
|
|
|
{_, DsName} = lists:split(2, atom_to_list(Ds)), |
|
|
|
printLog("~-10.s ~8.s ~12.s ~12.s ~10.s ~12.s ~10.s ~14.s ~10.s ~12.s ~12.s ~12.s ~n", |
|
|
|
[DsName, integer_to_list(Num), timeToStr(Insert), calcPer(Insert, Num), timeToStr(Read), calcPer(Read, Num), timeToStr(Update), calcPer(Update, Num), timeToStr(For), calcPer(For, Num), timeToStr(Delete), calcPer(Delete, Num)]); |
|
|
|
printLog("~-10.s ~8.s ~12.s ~12.s ~10.s ~12.s ~10.s ~14.s ~10.s ~12.s ~12.s ~12.s ~12.s ~n", |
|
|
|
[DsName, integer_to_list(Num), timeToStr(Insert), calcPer(Insert, Num), timeToStr(Read), calcPer(Read, Num), timeToStr(Update), calcPer(Update, Num), timeToStr(For), calcPer(For, Num), timeToStr(Delete), calcPer(Delete, Num), sizeToStr(TermSize)]); |
|
|
|
{'EXIT', Pid, normal} -> |
|
|
|
ok; |
|
|
|
_ShutDown -> |
|
|
@ -72,10 +73,10 @@ runAvg([], _VNumList) -> |
|
|
|
ok. |
|
|
|
|
|
|
|
runCal([Num | T], Ds) -> |
|
|
|
#tempCnt{insert = InsertList, read = ReadList, update = UpdateList, for = ForList, delete = DeleteList} = getStatistics(Ds, Num), |
|
|
|
#tempCnt{insert = InsertList, read = ReadList, update = UpdateList, for = ForList, delete = DeleteList, size = SizeList} = getStatistics(Ds, Num), |
|
|
|
{_, DsName} = lists:split(2, atom_to_list(Ds)), |
|
|
|
printLog("~-10.s ~8.s ~12.s ~12.s ~14.s ~12.s ~12.s~n", |
|
|
|
[DsName, integer_to_list(Num), calcAvg(InsertList, Num), calcAvg(ReadList, Num), calcAvg(UpdateList, Num), calcAvg(ForList, Num), calcAvg(DeleteList, Num)]), |
|
|
|
printLog("~-10.s ~8.s ~12.s ~12.s ~14.s ~12.s ~12.s ~12.s~n", |
|
|
|
[DsName, integer_to_list(Num), calcAvgT(InsertList, Num), calcAvgT(ReadList, Num), calcAvgT(UpdateList, Num), calcAvgT(ForList, Num), calcAvgT(DeleteList, Num), calcAvgS(SizeList, Num)]), |
|
|
|
runCal(T, Ds); |
|
|
|
runCal([], _Ds) -> |
|
|
|
ok. |
|
|
@ -105,6 +106,11 @@ timeToStr(Time) when Time > ?US -> |
|
|
|
timeToStr(Time) -> |
|
|
|
integer_to_list(Time) ++ "ns". |
|
|
|
|
|
|
|
sizeToStr(no_size) -> |
|
|
|
<<"noSize">>; |
|
|
|
sizeToStr(TermSize) -> |
|
|
|
integer_to_list(TermSize). |
|
|
|
|
|
|
|
calcPer(not_support, _Num) -> |
|
|
|
<<"notSupport">>; |
|
|
|
calcPer(skip, _Num) -> |
|
|
@ -112,39 +118,50 @@ calcPer(skip, _Num) -> |
|
|
|
calcPer(Time, Num) -> |
|
|
|
float_to_list(Time / Num, [{decimals, 2}]) ++ "ns". |
|
|
|
|
|
|
|
calcAvg([not_support | _], Num) -> |
|
|
|
calcAvgS([no_size | _], Num) -> |
|
|
|
<<"noSize">>; |
|
|
|
calcAvgS(CntList, Num) -> |
|
|
|
%% 去掉最大值与最小值 然后求平均值 |
|
|
|
AvgCnt = ?Cnt - 2, |
|
|
|
SortList = lists:sort(CntList), |
|
|
|
AvgList = lists:sublist(SortList, 2, AvgCnt), |
|
|
|
float_to_list(lists:sum(AvgList) / AvgCnt / Num, [{decimals, 2}]). |
|
|
|
|
|
|
|
calcAvgT([not_support | _], Num) -> |
|
|
|
<<"notSupport">>; |
|
|
|
calcAvg([skip | _], Num) -> |
|
|
|
calcAvgT([skip | _], Num) -> |
|
|
|
<<"skip">>; |
|
|
|
calcAvg(CntList, Num) -> |
|
|
|
calcAvgT([no_size | _], Num) -> |
|
|
|
<<"noSize">>; |
|
|
|
calcAvgT(CntList, Num) -> |
|
|
|
%% 去掉最大值与最小值 然后求平均值 |
|
|
|
AvgCnt = ?Cnt - 2, |
|
|
|
SortList = lists:sort(CntList), |
|
|
|
AvgList = lists:sublist(SortList, 2, AvgCnt), |
|
|
|
float_to_list(lists:sum(AvgList) / AvgCnt / Num, [{decimals, 2}]) ++ "ns". |
|
|
|
|
|
|
|
storeStatistics(Ds, Num, Insert, Read, Update, For, Delete) -> |
|
|
|
#tempCnt{insert = InsertList, read = ReadList, update = UpdateList, for = ForList, delete = DeleteList} = |
|
|
|
storeStatistics(Ds, Num, Insert, Read, Update, For, Delete, TermSize) -> |
|
|
|
#tempCnt{insert = InsertList, read = ReadList, update = UpdateList, for = ForList, delete = DeleteList, size = SizeList} = |
|
|
|
case erlang:get({Ds, Num}) of |
|
|
|
undefined -> |
|
|
|
#tempCnt{}; |
|
|
|
TempCnt -> |
|
|
|
TempCnt |
|
|
|
end, |
|
|
|
NewTempCnt = #tempCnt{insert = [Insert | InsertList], read = [Read | ReadList], update = [Update | UpdateList], for = [For | ForList], delete = [Delete | DeleteList]}, |
|
|
|
NewTempCnt = #tempCnt{insert = [Insert | InsertList], read = [Read | ReadList], update = [Update | UpdateList], for = [For | ForList], delete = [Delete | DeleteList], size = [TermSize | SizeList]}, |
|
|
|
erlang:put({Ds, Num}, NewTempCnt). |
|
|
|
|
|
|
|
getStatistics(Ds, Num) -> |
|
|
|
erlang:get({Ds, Num}). |
|
|
|
|
|
|
|
printTitle() -> |
|
|
|
printLog("~n~-10.s ~8.s ~12.s ~12.s ~10.s ~12.s ~10.s ~14.s ~10.s ~12.s ~12.s ~12.s ~n", |
|
|
|
["DsName", "V_Num", "insert", "insert/per", "read", "read/per", "update", "update/per", "for", "for/per", "delete", "delete/per"]), |
|
|
|
printLog("~n~-10.s ~8.s ~12.s ~12.s ~10.s ~12.s ~10.s ~14.s ~10.s ~12.s ~12.s ~12.s ~12.s ~n", |
|
|
|
["DsName", "V_Num", "insert", "insert/per", "read", "read/per", "update", "update/per", "for", "for/per", "delete", "delete/per", "termSize"]), |
|
|
|
printLog("~s ~n", [[$= || _ <- lists:seq(1, 145)]]). |
|
|
|
|
|
|
|
printAvg() -> |
|
|
|
printLog("~n~-10.s ~8.s ~12.s ~12.s ~14.s ~12.s ~12.s~n", |
|
|
|
["DsName", "V_Num", "insert/per", "read/per", "update/per", "for/per", "delete/per"]), |
|
|
|
printLog("~n~-10.s ~8.s ~12.s ~12.s ~14.s ~12.s ~12.s ~12.s~n", |
|
|
|
["DsName", "V_Num", "insert/per", "read/per", "update/per", "for/per", "delete/per", termSize]), |
|
|
|
printLog("~s ~n", [[$= || _ <- lists:seq(1, 85)]]). |
|
|
|
|
|
|
|
printLog(Format, Args) -> |