From b985c6bc1d8064ffe2bb0c753bf6bb55dddd85a5 Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Mon, 7 Nov 2022 17:31:58 -0800 Subject: [PATCH] [Benchmarks] Update/fix ShareableSet benchmarks --- Benchmarks/Libraries/ShareableSet.json | 394 ++++++++++++------ .../Benchmarks/ShareableSetBenchmarks.swift | 235 ++++++----- 2 files changed, 377 insertions(+), 252 deletions(-) diff --git a/Benchmarks/Libraries/ShareableSet.json b/Benchmarks/Libraries/ShareableSet.json index fd46f106..aa84b21f 100644 --- a/Benchmarks/Libraries/ShareableSet.json +++ b/Benchmarks/Libraries/ShareableSet.json @@ -29,13 +29,24 @@ "charts": [ { "kind": "chart", - "title": "union with Self", + "title": "union with Self, distinct", "tasks": [ - "ShareableSet union with Self (0% overlap)", - "ShareableSet union with Self (25% overlap)", - "ShareableSet union with Self (50% overlap)", - "ShareableSet union with Self (75% overlap)", - "ShareableSet union with Self (100% overlap)", + "ShareableSet union with Self (0% overlap, distinct)", + "ShareableSet union with Self (25% overlap, distinct)", + "ShareableSet union with Self (50% overlap, distinct)", + "ShareableSet union with Self (75% overlap, distinct)", + "ShareableSet union with Self (100% overlap, distinct)", + ] + }, + { + "kind": "chart", + "title": "union with Self, shared", + "tasks": [ + "ShareableSet union with Self (0% overlap, shared)", + "ShareableSet union with Self (25% overlap, shared)", + "ShareableSet union with Self (50% overlap, shared)", + "ShareableSet union with Self (75% overlap, shared)", + "ShareableSet union with Self (100% overlap, shared)", ] }, { @@ -51,13 +62,24 @@ }, { "kind": "chart", - "title": "formUnion with Self", + "title": "formUnion with Self, distinct", "tasks": [ - "ShareableSet formUnion with Self (0% overlap)", - "ShareableSet formUnion with Self (25% overlap)", - "ShareableSet formUnion with Self (50% overlap)", - "ShareableSet formUnion with Self (75% overlap)", - "ShareableSet formUnion with Self (100% overlap)", + "ShareableSet formUnion with Self (0% overlap, distinct)", + "ShareableSet formUnion with Self (25% overlap, distinct)", + "ShareableSet formUnion with Self (50% overlap, distinct)", + "ShareableSet formUnion with Self (75% overlap, distinct)", + "ShareableSet formUnion with Self (100% overlap, distinct)", + ] + }, + { + "kind": "chart", + "title": "formUnion with Self, shared", + "tasks": [ + "ShareableSet formUnion with Self (0% overlap, shared)", + "ShareableSet formUnion with Self (25% overlap, shared)", + "ShareableSet formUnion with Self (50% overlap, shared)", + "ShareableSet formUnion with Self (75% overlap, shared)", + "ShareableSet formUnion with Self (100% overlap, shared)", ] }, { @@ -78,13 +100,24 @@ "charts": [ { "kind": "chart", - "title": "intersection with Self", + "title": "intersection with Self, distinct", "tasks": [ - "ShareableSet intersection with Self (0% overlap)", - "ShareableSet intersection with Self (25% overlap)", - "ShareableSet intersection with Self (50% overlap)", - "ShareableSet intersection with Self (75% overlap)", - "ShareableSet intersection with Self (100% overlap)", + "ShareableSet intersection with Self (0% overlap, distinct)", + "ShareableSet intersection with Self (25% overlap, distinct)", + "ShareableSet intersection with Self (50% overlap, distinct)", + "ShareableSet intersection with Self (75% overlap, distinct)", + "ShareableSet intersection with Self (100% overlap, distinct)", + ] + }, + { + "kind": "chart", + "title": "intersection with Self, shared", + "tasks": [ + "ShareableSet intersection with Self (0% overlap, shared)", + "ShareableSet intersection with Self (25% overlap, shared)", + "ShareableSet intersection with Self (50% overlap, shared)", + "ShareableSet intersection with Self (75% overlap, shared)", + "ShareableSet intersection with Self (100% overlap, shared)", ] }, { @@ -100,13 +133,24 @@ }, { "kind": "chart", - "title": "formIntersection with Self", + "title": "formIntersection with Self, distinct", "tasks": [ - "ShareableSet formIntersection with Self (0% overlap)", - "ShareableSet formIntersection with Self (25% overlap)", - "ShareableSet formIntersection with Self (50% overlap)", - "ShareableSet formIntersection with Self (75% overlap)", - "ShareableSet formIntersection with Self (100% overlap)", + "ShareableSet formIntersection with Self (0% overlap, distinct)", + "ShareableSet formIntersection with Self (25% overlap, distinct)", + "ShareableSet formIntersection with Self (50% overlap, distinct)", + "ShareableSet formIntersection with Self (75% overlap, distinct)", + "ShareableSet formIntersection with Self (100% overlap, distinct)", + ] + }, + { + "kind": "chart", + "title": "formIntersection with Self, shared", + "tasks": [ + "ShareableSet formIntersection with Self (0% overlap, shared)", + "ShareableSet formIntersection with Self (25% overlap, shared)", + "ShareableSet formIntersection with Self (50% overlap, shared)", + "ShareableSet formIntersection with Self (75% overlap, shared)", + "ShareableSet formIntersection with Self (100% overlap, shared)", ] }, { @@ -127,13 +171,24 @@ "charts": [ { "kind": "chart", - "title": "symmetricDifference with Self", + "title": "symmetricDifference with Self, distinct", "tasks": [ - "ShareableSet symmetricDifference with Self (0% overlap)", - "ShareableSet symmetricDifference with Self (25% overlap)", - "ShareableSet symmetricDifference with Self (50% overlap)", - "ShareableSet symmetricDifference with Self (75% overlap)", - "ShareableSet symmetricDifference with Self (100% overlap)", + "ShareableSet symmetricDifference with Self (0% overlap, distinct)", + "ShareableSet symmetricDifference with Self (25% overlap, distinct)", + "ShareableSet symmetricDifference with Self (50% overlap, distinct)", + "ShareableSet symmetricDifference with Self (75% overlap, distinct)", + "ShareableSet symmetricDifference with Self (100% overlap, distinct)", + ] + }, + { + "kind": "chart", + "title": "symmetricDifference with Self, shared", + "tasks": [ + "ShareableSet symmetricDifference with Self (0% overlap, shared)", + "ShareableSet symmetricDifference with Self (25% overlap, shared)", + "ShareableSet symmetricDifference with Self (50% overlap, shared)", + "ShareableSet symmetricDifference with Self (75% overlap, shared)", + "ShareableSet symmetricDifference with Self (100% overlap, shared)", ] }, { @@ -149,13 +204,24 @@ }, { "kind": "chart", - "title": "formSymmetricDifference with Self", + "title": "formSymmetricDifference with Self, distinct", "tasks": [ - "ShareableSet formSymmetricDifference with Self (0% overlap)", - "ShareableSet formSymmetricDifference with Self (25% overlap)", - "ShareableSet formSymmetricDifference with Self (50% overlap)", - "ShareableSet formSymmetricDifference with Self (75% overlap)", - "ShareableSet formSymmetricDifference with Self (100% overlap)", + "ShareableSet formSymmetricDifference with Self (0% overlap, distinct)", + "ShareableSet formSymmetricDifference with Self (25% overlap, distinct)", + "ShareableSet formSymmetricDifference with Self (50% overlap, distinct)", + "ShareableSet formSymmetricDifference with Self (75% overlap, distinct)", + "ShareableSet formSymmetricDifference with Self (100% overlap, distinct)", + ] + }, + { + "kind": "chart", + "title": "formSymmetricDifference with Self, shared", + "tasks": [ + "ShareableSet formSymmetricDifference with Self (0% overlap, shared)", + "ShareableSet formSymmetricDifference with Self (25% overlap, shared)", + "ShareableSet formSymmetricDifference with Self (50% overlap, shared)", + "ShareableSet formSymmetricDifference with Self (75% overlap, shared)", + "ShareableSet formSymmetricDifference with Self (100% overlap, shared)", ] }, { @@ -176,13 +242,24 @@ "charts": [ { "kind": "chart", - "title": "subtracting Self", + "title": "subtracting Self, distinct", "tasks": [ - "ShareableSet subtracting Self (0% overlap)", - "ShareableSet subtracting Self (25% overlap)", - "ShareableSet subtracting Self (50% overlap)", - "ShareableSet subtracting Self (75% overlap)", - "ShareableSet subtracting Self (100% overlap)", + "ShareableSet subtracting Self (0% overlap, distinct)", + "ShareableSet subtracting Self (25% overlap, distinct)", + "ShareableSet subtracting Self (50% overlap, distinct)", + "ShareableSet subtracting Self (75% overlap, distinct)", + "ShareableSet subtracting Self (100% overlap, distinct)", + ] + }, + { + "kind": "chart", + "title": "subtracting Self, shared", + "tasks": [ + "ShareableSet subtracting Self (0% overlap, shared)", + "ShareableSet subtracting Self (25% overlap, shared)", + "ShareableSet subtracting Self (50% overlap, shared)", + "ShareableSet subtracting Self (75% overlap, shared)", + "ShareableSet subtracting Self (100% overlap, shared)", ] }, { @@ -198,13 +275,24 @@ }, { "kind": "chart", - "title": "subtract Self", + "title": "subtract Self, distinct", "tasks": [ - "ShareableSet subtract Self (0% overlap)", - "ShareableSet subtract Self (25% overlap)", - "ShareableSet subtract Self (50% overlap)", - "ShareableSet subtract Self (75% overlap)", - "ShareableSet subtract Self (100% overlap)", + "ShareableSet subtract Self (0% overlap, distinct)", + "ShareableSet subtract Self (25% overlap, distinct)", + "ShareableSet subtract Self (50% overlap, distinct)", + "ShareableSet subtract Self (75% overlap, distinct)", + "ShareableSet subtract Self (100% overlap, distinct)", + ] + }, + { + "kind": "chart", + "title": "subtract Self, shared", + "tasks": [ + "ShareableSet subtract Self (0% overlap, shared)", + "ShareableSet subtract Self (25% overlap, shared)", + "ShareableSet subtract Self (50% overlap, shared)", + "ShareableSet subtract Self (75% overlap, shared)", + "ShareableSet subtract Self (100% overlap, shared)", ] }, { @@ -292,15 +380,7 @@ }, { "kind": "chart", - "title": "diffing", - "tasks": [ - "ShareableSet insert one + subtract, shared", - "Set insert one + subtract, shared", - ] - }, - { - "kind": "chart", - "title": "diffing2", + "title": "model building with constant diffing", "tasks": [ "ShareableSet model diffing", "Set model diffing", @@ -323,8 +403,9 @@ "kind": "chart", "title": "union (0% overlap)", "tasks": [ - "OrderedSet union with Self (0% overlap)", - "OrderedSet union with Array (0% overlap)", + "ShareableSet union with Self (0% overlap, distinct)", + "ShareableSet union with Self (0% overlap, shared)", + "ShareableSet union with Array (0% overlap)", "Set union with Self (0% overlap)", "Set union with Array (0% overlap)", ] @@ -333,8 +414,9 @@ "kind": "chart", "title": "union (25% overlap)", "tasks": [ - "OrderedSet union with Self (25% overlap)", - "OrderedSet union with Array (25% overlap)", + "ShareableSet union with Self (25% overlap, distinct)", + "ShareableSet union with Self (25% overlap, shared)", + "ShareableSet union with Array (25% overlap)", "Set union with Self (25% overlap)", "Set union with Array (25% overlap)", ] @@ -343,8 +425,9 @@ "kind": "chart", "title": "union (50% overlap)", "tasks": [ - "OrderedSet union with Self (50% overlap)", - "OrderedSet union with Array (50% overlap)", + "ShareableSet union with Self (50% overlap, distinct)", + "ShareableSet union with Self (50% overlap, shared)", + "ShareableSet union with Array (50% overlap)", "Set union with Self (50% overlap)", "Set union with Array (50% overlap)", ] @@ -353,8 +436,9 @@ "kind": "chart", "title": "union (75% overlap)", "tasks": [ - "OrderedSet union with Self (75% overlap)", - "OrderedSet union with Array (75% overlap)", + "ShareableSet union with Self (75% overlap, distinct)", + "ShareableSet union with Self (75% overlap, shared)", + "ShareableSet union with Array (75% overlap)", "Set union with Self (75% overlap)", "Set union with Array (75% overlap)", ] @@ -363,8 +447,9 @@ "kind": "chart", "title": "union (100% overlap)", "tasks": [ - "OrderedSet union with Self (100% overlap)", - "OrderedSet union with Array (100% overlap)", + "ShareableSet union with Self (100% overlap, distinct)", + "ShareableSet union with Self (100% overlap, shared)", + "ShareableSet union with Array (100% overlap)", "Set union with Self (100% overlap)", "Set union with Array (100% overlap)", ] @@ -378,8 +463,9 @@ "kind": "chart", "title": "formUnion (0% overlap)", "tasks": [ - "OrderedSet formUnion with Self (0% overlap)", - "OrderedSet formUnion with Array (0% overlap)", + "ShareableSet formUnion with Self (0% overlap, distinct)", + "ShareableSet formUnion with Self (0% overlap, shared)", + "ShareableSet formUnion with Array (0% overlap)", "Set formUnion with Self (0% overlap)", "Set formUnion with Array (0% overlap)", ] @@ -388,8 +474,9 @@ "kind": "chart", "title": "formUnion (25% overlap)", "tasks": [ - "OrderedSet formUnion with Self (25% overlap)", - "OrderedSet formUnion with Array (25% overlap)", + "ShareableSet formUnion with Self (25% overlap, distinct)", + "ShareableSet formUnion with Self (25% overlap, shared)", + "ShareableSet formUnion with Array (25% overlap)", "Set formUnion with Self (25% overlap)", "Set formUnion with Array (25% overlap)", ] @@ -398,8 +485,9 @@ "kind": "chart", "title": "formUnion (50% overlap)", "tasks": [ - "OrderedSet formUnion with Self (50% overlap)", - "OrderedSet formUnion with Array (50% overlap)", + "ShareableSet formUnion with Self (50% overlap, distinct)", + "ShareableSet formUnion with Self (50% overlap, shared)", + "ShareableSet formUnion with Array (50% overlap)", "Set formUnion with Self (50% overlap)", "Set formUnion with Array (50% overlap)", ] @@ -408,8 +496,9 @@ "kind": "chart", "title": "formUnion (75% overlap)", "tasks": [ - "OrderedSet formUnion with Self (75% overlap)", - "OrderedSet formUnion with Array (75% overlap)", + "ShareableSet formUnion with Self (75% overlap, distinct)", + "ShareableSet formUnion with Self (75% overlap, shared)", + "ShareableSet formUnion with Array (75% overlap)", "Set formUnion with Self (75% overlap)", "Set formUnion with Array (75% overlap)", ] @@ -418,8 +507,9 @@ "kind": "chart", "title": "formUnion (100% overlap)", "tasks": [ - "OrderedSet formUnion with Self (100% overlap)", - "OrderedSet formUnion with Array (100% overlap)", + "ShareableSet formUnion with Self (100% overlap, distinct)", + "ShareableSet formUnion with Self (100% overlap, shared)", + "ShareableSet formUnion with Array (100% overlap)", "Set formUnion with Self (100% overlap)", "Set formUnion with Array (100% overlap)", ] @@ -433,8 +523,9 @@ "kind": "chart", "title": "intersection (0% overlap)", "tasks": [ - "OrderedSet intersection with Self (0% overlap)", - "OrderedSet intersection with Array (0% overlap)", + "ShareableSet intersection with Self (0% overlap, distinct)", + "ShareableSet intersection with Self (0% overlap, shared)", + "ShareableSet intersection with Array (0% overlap)", "Set intersection with Self (0% overlap)", "Set intersection with Array (0% overlap)", ] @@ -443,8 +534,9 @@ "kind": "chart", "title": "intersection (25% overlap)", "tasks": [ - "OrderedSet intersection with Self (25% overlap)", - "OrderedSet intersection with Array (25% overlap)", + "ShareableSet intersection with Self (25% overlap, distinct)", + "ShareableSet intersection with Self (25% overlap, shared)", + "ShareableSet intersection with Array (25% overlap)", "Set intersection with Self (25% overlap)", "Set intersection with Array (25% overlap)", ] @@ -453,8 +545,9 @@ "kind": "chart", "title": "intersection (50% overlap)", "tasks": [ - "OrderedSet intersection with Self (50% overlap)", - "OrderedSet intersection with Array (50% overlap)", + "ShareableSet intersection with Self (50% overlap, distinct)", + "ShareableSet intersection with Self (50% overlap, shared)", + "ShareableSet intersection with Array (50% overlap)", "Set intersection with Self (50% overlap)", "Set intersection with Array (50% overlap)", ] @@ -463,8 +556,9 @@ "kind": "chart", "title": "intersection (75% overlap)", "tasks": [ - "OrderedSet intersection with Self (75% overlap)", - "OrderedSet intersection with Array (75% overlap)", + "ShareableSet intersection with Self (75% overlap, distinct)", + "ShareableSet intersection with Self (75% overlap, shared)", + "ShareableSet intersection with Array (75% overlap)", "Set intersection with Self (75% overlap)", "Set intersection with Array (75% overlap)", ] @@ -473,8 +567,9 @@ "kind": "chart", "title": "intersection (100% overlap)", "tasks": [ - "OrderedSet intersection with Self (100% overlap)", - "OrderedSet intersection with Array (100% overlap)", + "ShareableSet intersection with Self (100% overlap, distinct)", + "ShareableSet intersection with Self (100% overlap, shared)", + "ShareableSet intersection with Array (100% overlap)", "Set intersection with Self (100% overlap)", "Set intersection with Array (100% overlap)", ] @@ -488,8 +583,9 @@ "kind": "chart", "title": "formIntersection (0% overlap)", "tasks": [ - "OrderedSet formIntersection with Self (0% overlap)", - "OrderedSet formIntersection with Array (0% overlap)", + "ShareableSet formIntersection with Self (0% overlap, distinct)", + "ShareableSet formIntersection with Self (0% overlap, shared)", + "ShareableSet formIntersection with Array (0% overlap)", "Set formIntersection with Self (0% overlap)", "Set formIntersection with Array (0% overlap)", ] @@ -498,8 +594,9 @@ "kind": "chart", "title": "formIntersection (25% overlap)", "tasks": [ - "OrderedSet formIntersection with Self (25% overlap)", - "OrderedSet formIntersection with Array (25% overlap)", + "ShareableSet formIntersection with Self (25% overlap, distinct)", + "ShareableSet formIntersection with Self (25% overlap, shared)", + "ShareableSet formIntersection with Array (25% overlap)", "Set formIntersection with Self (25% overlap)", "Set formIntersection with Array (25% overlap)", ] @@ -508,8 +605,9 @@ "kind": "chart", "title": "formIntersection (50% overlap)", "tasks": [ - "OrderedSet formIntersection with Self (50% overlap)", - "OrderedSet formIntersection with Array (50% overlap)", + "ShareableSet formIntersection with Self (50% overlap, distinct)", + "ShareableSet formIntersection with Self (50% overlap, shared)", + "ShareableSet formIntersection with Array (50% overlap)", "Set formIntersection with Self (50% overlap)", "Set formIntersection with Array (50% overlap)", ] @@ -518,8 +616,9 @@ "kind": "chart", "title": "formIntersection (75% overlap)", "tasks": [ - "OrderedSet formIntersection with Self (75% overlap)", - "OrderedSet formIntersection with Array (75% overlap)", + "ShareableSet formIntersection with Self (75% overlap, distinct)", + "ShareableSet formIntersection with Self (75% overlap, shared)", + "ShareableSet formIntersection with Array (75% overlap)", "Set formIntersection with Self (75% overlap)", "Set formIntersection with Array (75% overlap)", ] @@ -528,8 +627,9 @@ "kind": "chart", "title": "formIntersection (100% overlap)", "tasks": [ - "OrderedSet formIntersection with Self (100% overlap)", - "OrderedSet formIntersection with Array (100% overlap)", + "ShareableSet formIntersection with Self (100% overlap, distinct)", + "ShareableSet formIntersection with Self (100% overlap, shared)", + "ShareableSet formIntersection with Array (100% overlap)", "Set formIntersection with Self (100% overlap)", "Set formIntersection with Array (100% overlap)", ] @@ -543,8 +643,9 @@ "kind": "chart", "title": "symmetricDifference (0% overlap)", "tasks": [ - "OrderedSet symmetricDifference with Self (0% overlap)", - "OrderedSet symmetricDifference with Array (0% overlap)", + "ShareableSet symmetricDifference with Self (0% overlap, distinct)", + "ShareableSet symmetricDifference with Self (0% overlap, shared)", + "ShareableSet symmetricDifference with Array (0% overlap)", "Set symmetricDifference with Self (0% overlap)", "Set symmetricDifference with Array (0% overlap)", ] @@ -553,8 +654,9 @@ "kind": "chart", "title": "symmetricDifference (25% overlap)", "tasks": [ - "OrderedSet symmetricDifference with Self (25% overlap)", - "OrderedSet symmetricDifference with Array (25% overlap)", + "ShareableSet symmetricDifference with Self (25% overlap, distinct)", + "ShareableSet symmetricDifference with Self (25% overlap, shared)", + "ShareableSet symmetricDifference with Array (25% overlap)", "Set symmetricDifference with Self (25% overlap)", "Set symmetricDifference with Array (25% overlap)", ] @@ -563,8 +665,9 @@ "kind": "chart", "title": "symmetricDifference (50% overlap)", "tasks": [ - "OrderedSet symmetricDifference with Self (50% overlap)", - "OrderedSet symmetricDifference with Array (50% overlap)", + "ShareableSet symmetricDifference with Self (50% overlap, distinct)", + "ShareableSet symmetricDifference with Self (50% overlap, shared)", + "ShareableSet symmetricDifference with Array (50% overlap)", "Set symmetricDifference with Self (50% overlap)", "Set symmetricDifference with Array (50% overlap)", ] @@ -573,8 +676,9 @@ "kind": "chart", "title": "symmetricDifference (75% overlap)", "tasks": [ - "OrderedSet symmetricDifference with Self (75% overlap)", - "OrderedSet symmetricDifference with Array (75% overlap)", + "ShareableSet symmetricDifference with Self (75% overlap, distinct)", + "ShareableSet symmetricDifference with Self (75% overlap, shared)", + "ShareableSet symmetricDifference with Array (75% overlap)", "Set symmetricDifference with Self (75% overlap)", "Set symmetricDifference with Array (75% overlap)", ] @@ -583,8 +687,9 @@ "kind": "chart", "title": "symmetricDifference (100% overlap)", "tasks": [ - "OrderedSet symmetricDifference with Self (100% overlap)", - "OrderedSet symmetricDifference with Array (100% overlap)", + "ShareableSet symmetricDifference with Self (100% overlap, distinct)", + "ShareableSet symmetricDifference with Self (100% overlap, shared)", + "ShareableSet symmetricDifference with Array (100% overlap)", "Set symmetricDifference with Self (100% overlap)", "Set symmetricDifference with Array (100% overlap)", ] @@ -598,8 +703,9 @@ "kind": "chart", "title": "formSymmetricDifference (0% overlap)", "tasks": [ - "OrderedSet formSymmetricDifference with Self (0% overlap)", - "OrderedSet formSymmetricDifference with Array (0% overlap)", + "ShareableSet formSymmetricDifference with Self (0% overlap, distinct)", + "ShareableSet formSymmetricDifference with Self (0% overlap, shared)", + "ShareableSet formSymmetricDifference with Array (0% overlap)", "Set formSymmetricDifference with Self (0% overlap)", "Set formSymmetricDifference with Array (0% overlap)", ] @@ -608,8 +714,9 @@ "kind": "chart", "title": "formSymmetricDifference (25% overlap)", "tasks": [ - "OrderedSet formSymmetricDifference with Self (25% overlap)", - "OrderedSet formSymmetricDifference with Array (25% overlap)", + "ShareableSet formSymmetricDifference with Self (25% overlap, distinct)", + "ShareableSet formSymmetricDifference with Self (25% overlap, shared)", + "ShareableSet formSymmetricDifference with Array (25% overlap)", "Set formSymmetricDifference with Self (25% overlap)", "Set formSymmetricDifference with Array (25% overlap)", ] @@ -618,8 +725,9 @@ "kind": "chart", "title": "formSymmetricDifference (50% overlap)", "tasks": [ - "OrderedSet formSymmetricDifference with Self (50% overlap)", - "OrderedSet formSymmetricDifference with Array (50% overlap)", + "ShareableSet formSymmetricDifference with Self (50% overlap, distinct)", + "ShareableSet formSymmetricDifference with Self (50% overlap, shared)", + "ShareableSet formSymmetricDifference with Array (50% overlap)", "Set formSymmetricDifference with Self (50% overlap)", "Set formSymmetricDifference with Array (50% overlap)", ] @@ -628,8 +736,9 @@ "kind": "chart", "title": "formSymmetricDifference (75% overlap)", "tasks": [ - "OrderedSet formSymmetricDifference with Self (75% overlap)", - "OrderedSet formSymmetricDifference with Array (75% overlap)", + "ShareableSet formSymmetricDifference with Self (75% overlap, distinct)", + "ShareableSet formSymmetricDifference with Self (75% overlap, shared)", + "ShareableSet formSymmetricDifference with Array (75% overlap)", "Set formSymmetricDifference with Self (75% overlap)", "Set formSymmetricDifference with Array (75% overlap)", ] @@ -638,8 +747,9 @@ "kind": "chart", "title": "formSymmetricDifference (100% overlap)", "tasks": [ - "OrderedSet formSymmetricDifference with Self (100% overlap)", - "OrderedSet formSymmetricDifference with Array (100% overlap)", + "ShareableSet formSymmetricDifference with Self (100% overlap, distinct)", + "ShareableSet formSymmetricDifference with Self (100% overlap, shared)", + "ShareableSet formSymmetricDifference with Array (100% overlap)", "Set formSymmetricDifference with Self (100% overlap)", "Set formSymmetricDifference with Array (100% overlap)", ] @@ -653,8 +763,9 @@ "kind": "chart", "title": "subtracting (0% overlap)", "tasks": [ - "OrderedSet subtracting Self (0% overlap)", - "OrderedSet subtracting Array (0% overlap)", + "ShareableSet subtracting Self (0% overlap, distinct)", + "ShareableSet subtracting Self (0% overlap, shared)", + "ShareableSet subtracting Array (0% overlap)", "Set subtracting Self (0% overlap)", "Set subtracting Array (0% overlap)", ] @@ -663,8 +774,9 @@ "kind": "chart", "title": "subtracting (25% overlap)", "tasks": [ - "OrderedSet subtracting Self (25% overlap)", - "OrderedSet subtracting Array (25% overlap)", + "ShareableSet subtracting Self (25% overlap, distinct)", + "ShareableSet subtracting Self (25% overlap, shared)", + "ShareableSet subtracting Array (25% overlap)", "Set subtracting Self (25% overlap)", "Set subtracting Array (25% overlap)", ] @@ -673,8 +785,9 @@ "kind": "chart", "title": "subtracting (50% overlap)", "tasks": [ - "OrderedSet subtracting Self (50% overlap)", - "OrderedSet subtracting Array (50% overlap)", + "ShareableSet subtracting Self (50% overlap, distinct)", + "ShareableSet subtracting Self (50% overlap, shared)", + "ShareableSet subtracting Array (50% overlap)", "Set subtracting Self (50% overlap)", "Set subtracting Array (50% overlap)", ] @@ -683,8 +796,9 @@ "kind": "chart", "title": "subtracting (75% overlap)", "tasks": [ - "OrderedSet subtracting Self (75% overlap)", - "OrderedSet subtracting Array (75% overlap)", + "ShareableSet subtracting Self (75% overlap, distinct)", + "ShareableSet subtracting Self (75% overlap, shared)", + "ShareableSet subtracting Array (75% overlap)", "Set subtracting Self (75% overlap)", "Set subtracting Array (75% overlap)", ] @@ -693,8 +807,9 @@ "kind": "chart", "title": "subtracting (100% overlap)", "tasks": [ - "OrderedSet subtracting Self (100% overlap)", - "OrderedSet subtracting Array (100% overlap)", + "ShareableSet subtracting Self (100% overlap, distinct)", + "ShareableSet subtracting Self (100% overlap, shared)", + "ShareableSet subtracting Array (100% overlap)", "Set subtracting Self (100% overlap)", "Set subtracting Array (100% overlap)", ] @@ -708,8 +823,9 @@ "kind": "chart", "title": "subtract (0% overlap)", "tasks": [ - "OrderedSet subtract Self (0% overlap)", - "OrderedSet subtract Array (0% overlap)", + "ShareableSet subtract Self (0% overlap, distinct)", + "ShareableSet subtract Self (0% overlap, shared)", + "ShareableSet subtract Array (0% overlap)", "Set subtract Self (0% overlap)", "Set subtract Array (0% overlap)", ] @@ -718,8 +834,9 @@ "kind": "chart", "title": "subtract (25% overlap)", "tasks": [ - "OrderedSet subtract Self (25% overlap)", - "OrderedSet subtract Array (25% overlap)", + "ShareableSet subtract Self (25% overlap, distinct)", + "ShareableSet subtract Self (25% overlap, shared)", + "ShareableSet subtract Array (25% overlap)", "Set subtract Self (25% overlap)", "Set subtract Array (25% overlap)", ] @@ -728,8 +845,9 @@ "kind": "chart", "title": "subtract (50% overlap)", "tasks": [ - "OrderedSet subtract Self (50% overlap)", - "OrderedSet subtract Array (50% overlap)", + "ShareableSet subtract Self (50% overlap, distinct)", + "ShareableSet subtract Self (50% overlap, shared)", + "ShareableSet subtract Array (50% overlap)", "Set subtract Self (50% overlap)", "Set subtract Array (50% overlap)", ] @@ -738,8 +856,9 @@ "kind": "chart", "title": "subtract (75% overlap)", "tasks": [ - "OrderedSet subtract Self (75% overlap)", - "OrderedSet subtract Array (75% overlap)", + "ShareableSet subtract Self (75% overlap, distinct)", + "ShareableSet subtract Self (75% overlap, shared)", + "ShareableSet subtract Array (75% overlap)", "Set subtract Self (75% overlap)", "Set subtract Array (75% overlap)", ] @@ -748,8 +867,9 @@ "kind": "chart", "title": "subtract (100% overlap)", "tasks": [ - "OrderedSet subtract Self (100% overlap)", - "OrderedSet subtract Array (100% overlap)", + "ShareableSet subtract Self (100% overlap, distinct)", + "ShareableSet subtract Self (100% overlap, shared)", + "ShareableSet subtract Array (100% overlap)", "Set subtract Self (100% overlap)", "Set subtract Array (100% overlap)", ] diff --git a/Benchmarks/Sources/Benchmarks/ShareableSetBenchmarks.swift b/Benchmarks/Sources/Benchmarks/ShareableSetBenchmarks.swift index 3749df34..73aceb72 100644 --- a/Benchmarks/Sources/Benchmarks/ShareableSetBenchmarks.swift +++ b/Benchmarks/Sources/Benchmarks/ShareableSetBenchmarks.swift @@ -105,21 +105,6 @@ extension Benchmark { blackHole(set) } - self.add( - title: "ShareableSet insert one + subtract, shared", - input: [Int].self - ) { input in - let original = ShareableSet(input) - let newMember = input.count - return { timer in - var copy = original - copy.insert(newMember) - let diff = copy.subtracting(original) - precondition(diff.count == 1 && diff.first == newMember) - blackHole(copy) - } - } - self.addSimple( title: "ShareableSet model diffing", input: Int.self @@ -184,58 +169,68 @@ extension Benchmark { // SetAlgebra operations with Self do { - for (percentage, start) in overlaps { - self.add( - title: "ShareableSet union with Self (\(percentage) overlap)", - input: [Int].self - ) { input in - let start = start(input.count) - let a = ShareableSet(input) - let b = ShareableSet(start ..< start + input.count) - return { timer in - blackHole(a.union(identity(b))) - } + func makeB( + _ a: ShareableSet, _ range: Range, shared: Bool + ) -> ShareableSet { + guard shared else { + return ShareableSet(range) } + var b = a + b.subtract(0 ..< range.lowerBound) + b.formUnion(range) + return b } for (percentage, start) in overlaps { - self.add( - title: "ShareableSet intersection with Self (\(percentage) overlap)", - input: [Int].self - ) { input in - let start = start(input.count) - let a = ShareableSet(input) - let b = ShareableSet(start ..< start + input.count) - return { timer in - blackHole(a.intersection(identity(b))) - } - } - } + for shared in [false, true] { + let qualifier = "\(percentage) overlap, \(shared ? "shared" : "distinct")" - for (percentage, start) in overlaps { - self.add( - title: "ShareableSet symmetricDifference with Self (\(percentage) overlap)", - input: [Int].self - ) { input in - let start = start(input.count) - let a = ShareableSet(input) - let b = ShareableSet(start ..< start + input.count) - return { timer in - blackHole(a.symmetricDifference(identity(b))) + self.add( + title: "ShareableSet union with Self (\(qualifier))", + input: [Int].self + ) { input in + let start = start(input.count) + let a = ShareableSet(input) + let b = makeB(a, start ..< start + input.count, shared: shared) + return { timer in + blackHole(a.union(identity(b))) + } } - } - } - for (percentage, start) in overlaps { - self.add( - title: "ShareableSet subtracting Self (\(percentage) overlap)", - input: [Int].self - ) { input in - let start = start(input.count) - let a = ShareableSet(input) - let b = ShareableSet(start ..< start + input.count) - return { timer in - blackHole(a.subtracting(identity(b))) + self.add( + title: "ShareableSet intersection with Self (\(qualifier))", + input: [Int].self + ) { input in + let start = start(input.count) + let a = ShareableSet(input) + let b = makeB(a, start ..< start + input.count, shared: shared) + return { timer in + blackHole(a.intersection(identity(b))) + } + } + + self.add( + title: "ShareableSet symmetricDifference with Self (\(qualifier))", + input: [Int].self + ) { input in + let start = start(input.count) + let a = ShareableSet(input) + let b = makeB(a, start ..< start + input.count, shared: shared) + return { timer in + blackHole(a.symmetricDifference(identity(b))) + } + } + + self.add( + title: "ShareableSet subtracting Self (\(qualifier))", + input: [Int].self + ) { input in + let start = start(input.count) + let a = ShareableSet(input) + let b = makeB(a, start ..< start + input.count, shared: shared) + return { timer in + blackHole(a.subtracting(identity(b))) + } } } } @@ -302,70 +297,80 @@ extension Benchmark { // SetAlgebra mutations with Self do { - for (percentage, start) in overlaps { - self.add( - title: "ShareableSet formUnion with Self (\(percentage) overlap)", - input: [Int].self - ) { input in - let start = start(input.count) - let b = ShareableSet(start ..< start + input.count) - return { timer in - var a = ShareableSet(input) - timer.measure { - a.formUnion(identity(b)) - } - blackHole(a) - } + func makeB( + _ a: ShareableSet, _ range: Range, shared: Bool + ) -> ShareableSet { + guard shared else { + return ShareableSet(range) } + var b = a + b.subtract(0 ..< range.lowerBound) + b.formUnion(range) + return b } for (percentage, start) in overlaps { - self.add( - title: "ShareableSet formIntersection with Self (\(percentage) overlap)", - input: [Int].self - ) { input in - let start = start(input.count) - let b = ShareableSet(start ..< start + input.count) - return { timer in - var a = ShareableSet(input) - timer.measure { - a.formIntersection(identity(b)) - } - blackHole(a) - } - } - } + for shared in [false, true] { + let qualifier = "\(percentage) overlap, \(shared ? "shared" : "distinct")" - for (percentage, start) in overlaps { - self.add( - title: "ShareableSet formSymmetricDifference with Self (\(percentage) overlap)", - input: [Int].self - ) { input in - let start = start(input.count) - let b = ShareableSet(start ..< start + input.count) - return { timer in - var a = ShareableSet(input) - timer.measure { - a.formSymmetricDifference(identity(b)) + self.add( + title: "ShareableSet formUnion with Self (\(qualifier))", + input: [Int].self + ) { input in + let start = start(input.count) + return { timer in + var a = ShareableSet(input) + let b = makeB(a, start ..< start + input.count, shared: shared) + timer.measure { + a.formUnion(identity(b)) + } + blackHole(a) } - blackHole(a) } - } - } - for (percentage, start) in overlaps { - self.add( - title: "ShareableSet subtract Self (\(percentage) overlap)", - input: [Int].self - ) { input in - let start = start(input.count) - let b = ShareableSet(start ..< start + input.count) - return { timer in - var a = ShareableSet(input) - timer.measure { - a.subtract(identity(b)) + self.add( + title: "ShareableSet formIntersection with Self (\(qualifier))", + input: [Int].self + ) { input in + let start = start(input.count) + return { timer in + var a = ShareableSet(input) + let b = makeB(a, start ..< start + input.count, shared: shared) + timer.measure { + a.formIntersection(identity(b)) + } + blackHole(a) + } + } + + self.add( + title: "ShareableSet formSymmetricDifference with Self (\(qualifier))", + input: [Int].self + ) { input in + let start = start(input.count) + return { timer in + var a = ShareableSet(input) + let b = makeB(a, start ..< start + input.count, shared: shared) + timer.measure { + a.formSymmetricDifference(identity(b)) + } + blackHole(a) + } + } + + self.add( + title: "ShareableSet subtract Self (\(qualifier))", + input: [Int].self + ) { input in + let start = start(input.count) + return { timer in + var a = ShareableSet(input) + let b = makeB(a, start ..< start + input.count, shared: shared) + timer.measure { + a.subtract(identity(b)) + } + blackHole(a) } - blackHole(a) } } }