-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathperformance.wlt
More file actions
96 lines (84 loc) · 2.91 KB
/
Copy pathperformance.wlt
File metadata and controls
96 lines (84 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<|
"performance" -> <|
"init" -> (
$init = {{0, 0}, {0, 0}, {0, 0}};
$rule =
{{{a_, b_}, {a_, c_}, {a_, d_}} :>
Module[{$0, $1, $2}, {
{$0, $1}, {$1, $2}, {$2, $0}, {$0, $2}, {$2, $1}, {$1, $0},
{$0, b}, {$1, c}, {$2, d}, {b, $2}, {d, $0}}]};
$largeSet = Hold[WolframModel[
{{1, 2, 3}} -> {{5, 6, 1}, {6, 4, 2}, {4, 5, 3}},
{{0, 0, 0}},
7,
"FinalState"]];
{$normalPlotTiming, $normalPlotMemory} =
AbsoluteTiming[MaxMemoryUsed[GraphPlot[Rule @@@ Catenate[Partition[#, 2, 1] & /@ ReleaseHold[$largeSet]]]]];
$edgeTypes = {"Ordered", "Cyclic"};
$hyperedgeRenderings = {"Subgraphs", "Polygons"};
),
"tests" -> {
With[{init = $init, rule = $rule}, {
(** C++ performance **)
VerificationTest[
Head[SetReplace[
init,
rule,
1000]],
List,
TimeConstraint -> 10,
MemoryConstraint -> 5*^6
],
(** WL performance **)
VerificationTest[
Head[SetReplace[
init,
rule,
#,
Method -> "Symbolic"]],
List,
TimeConstraint -> 60,
MemoryConstraint -> 5*^6
] & /@ {14, 100},
(** Naming function performance **)
VerificationTest[
Head[WolframModel[
<|"PatternRules" -> rule|>,
init,
<|"MaxEvents" -> 1000|>,
"FinalState",
"VertexNamingFunction" -> All]],
List,
TimeConstraint -> 10,
MemoryConstraint -> 10*^6
]
}],
(** C++ aborting **)
(* assumes example below runs slow, may need to be replaced in the future *)
VerificationTest[
(* it is possible for evaluation to finish slightly earlier than the constraint, hence the min of 0.8;
timing varies around +-0.05, so using tolerance 0.2 to avoid random failures *)
AbsoluteTiming[TimeConstrained[SetReplace[
{{0}},
ToPatternRules[{{{0}} -> {{0}, {0}, {0}}, {{0}, {0}, {0}} -> {{0}}}],
30], 1]][[1]],
1.0,
SameTest -> (Abs[#1 - #2] < 0.2 &),
TimeConstraint -> 3
],
(** HypergraphPlot **)
Table[
With[{edgeType = edgeType, hyperedgeRendering = hyperedgeRendering, $largeSet = $largeSet}, VerificationTest[
With[{largeSet = ReleaseHold[$largeSet]},
Head[HypergraphPlot[largeSet, edgeType, "HyperedgeRendering" -> hyperedgeRendering]]],
Graphics,
TimeConstraint -> (5 $normalPlotTiming),
MemoryConstraint -> (10 $normalPlotMemory)] /. HoldPattern[ReleaseHold[Hold[set_]]] -> set],
{edgeType, $edgeTypes},
{hyperedgeRendering, $hyperedgeRenderings}]
},
"options" -> {
"Parallel" -> False
}
|>
|>