MSE에 게시 된 벤치 마크 결과를 수집하고 분석하려면 어떻게해야합니까?

Nov 26 2020

여기에 게시 된 것과 같이 Mathematica Stack Exchange (MSE)에 게시 된 Mathematica / WL 벤치 마크 결과를 수집 하려면 어떻게해야합니까?

가정 :

  • 벤치 마크가 게시 된 답변이 여러 개 있습니다.

  • 벤치 마크 결과에는 명확한 "규칙 목록"형식이 있습니다.

보다:

Needs["Benchmarking`"]
Benchmark[]

(* {"MachineName" -> "macbook-pro", "System" -> "Mac OS X x86 (64-bit)", "BenchmarkName" -> "WolframMark", "FullVersionNumber" -> "12.1.1", "Date" -> "November 26, 2020",
 "BenchmarkResult" -> 3.028, "TotalTime" -> 4.571, "Results" -> {{"Data Fitting", 0.291}, {"Digits of Pi", 0.249}, {"Discrete Fourier Transform", 0.363}, {"Eigenvalues of a Matrix", 0.297},
   {"Elementary Functions", 0.375}, {"Gamma Function", 0.356}, {"Large Integer Multiplication", 0.323}, {"Matrix Arithmetic", 0.227}, {"Matrix Multiplication", 0.218}, {"Matrix Transpose", 0.404},
   {"Numerical Integration", 0.463}, {"Polynomial Expansion", 0.068}, {"Random Number Sort", 0.449}, {"Singular Value Decomposition", 0.221}, {"Solving a Linear System", 0.267}}} *)

답변

12 AntonAntonov Nov 26 2020 at 18:23

음식물 섭취

MSE 토론에서 모든 답변을 XML 객체로 가져옵니다.

xmlObject = 
  Import["https://mathematica.stackexchange.com/questions/234881/benchmarking-with-mathematica-v-12-for-up-to-date-comparision-of-mathematica-acr/235384#235384", "XMLObject"];

코드 XML 요소 가져 오기 :

lsRes1 = Cases[xmlObject, XMLElement["code", {}, code_] :> code, \[Infinity]];

(이 시점에서 코드 문자열을 얻습니다.)

Benchmark계산 명령을 제거 하고 코드 문자열을 WL 코드로 변환합니다.

lsRes2 = Map[
   ToExpression@
     StringReplace[#, {"BenchmarkReport[]" -> "", "Benchmark[]" -> ""}] &, lsRes1];
Length[lsRes2]

(*16*)

규칙 목록 인 코드 (블록)를 선택하십시오.

lsRes3 = Select[Flatten /@ lsRes2, MatchQ[#, {_Rule ..}] && Length[#] > 1 &];
Length[lsRes3]

(*10*)

각 코드 블록에 대해 메타 데이터 및 벤치 마크 결과를 연결로 평면화합니다.

lsRes4 = Map[Association@ Cases[Flatten[# /.  HoldPattern["Results" -> r_] :> (Rule @@@ r)], _Rule] &, lsRes3];
Length[lsRes4]

(*10*)

모든 연결에 동일한 키가 있는지 확인하십시오.

lsRes5 = 
 Block[{lsAllKeys = Union[Flatten[Keys /@ lsRes4]]}, 
  Map[Join[AssociationThread[lsAllKeys, "NA"], #] &, lsRes4]
 ];
Length[lsRes5]

(*10*)

(그렇지 않으면 얻은 데이터 세트를 일부 계산에 사용하기 어려울 수 있습니다.)

비교 데이터 세트를 만듭니다.

dsBenchmarks = Dataset[lsRes5];
dsBenchmarks = dsBenchmarks[SortBy[#BenchmarkResult &]]

기본 분석

데이터 세트를 요약합니다.

ResourceFunction["RecordsSummary"][dsBenchmarks]

(막대) 플롯 결과 :

Multicolumn@
 KeyValueMap[
  If[VectorQ[#2, NumericQ], 
    BarChart[#2, PlotLabel -> #1, PlotTheme -> "Detailed"], 
    Nothing
  ] &, 
  Normal@Transpose@dsBenchmarks
]

고장 통계

시스템 (또는 기타 기준) 당 벤치 마크 결과 분할 :

aRes = GroupBy[Normal@dsBenchmarks, #System &, Dataset];
aRes = Map[#[All, Select[#, NumericQ] &] &, aRes];

벤치 마크 구성 요소 결과에서 전체 벤치 마크 결과를 분리합니다.

aRes2 = Map[#[All, KeyTake[#, {"BenchmarkResult", "TotalTime"}] &] &, aRes];
aRes3 = Map[#[All, KeyDrop[#, {"BenchmarkResult", "TotalTime"}] &] &, aRes];

전체 벤치 마크 결과를 표시합니다.

aRes2

시스템 별 분포 통계 플롯 표시 :

aResPlots3 = 
  BoxWhiskerChart[Transpose[Normal[#[Values]]], 
     PlotLabel -> Row[{"Number of benchmarks:", Spacer[2], Length[#]}], 
     ChartStyle -> 56, ImageSize -> Medium, PlotTheme -> "Detailed", 
     ChartLegends -> Keys[Normal@#[[1]]]] & /@ aRes3;
Grid[List @@@ Normal[aResPlots3], Dividers -> All, FrameStyle -> GrayLevel[0.7]]

(참고, 우리는 시스템 당 사용 가능한 벤치 마크의 수를 주시해야합니다. 여기에서는 그 수가 너무 적습니다 ...)