Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ordered collection diffing benchmark #82

Merged
merged 2 commits into from
Oct 20, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update Readme
  • Loading branch information
ra1028 committed Oct 20, 2019
commit 44b9f9e6c943b5c8a40fc8f65ce74cfb302deaff
128 changes: 79 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,80 +182,102 @@ The frameworks and its version that compared is below.
- [RxDataSources](https://github.com/RxSwiftCommunity/RxDataSources) ([Differentiator](https://github.com/RxSwiftCommunity/RxDataSources/tree/master/Sources/Differentiator)) - 4.0.1
- [FlexibleDiff](https://github.com/RACCommunity/FlexibleDiff) - 0.0.8
- [IGListKit](https://github.com/Instagram/IGListKit) - 3.4.0
- [DeepDiff](https://github.com/onmyway133/DeepDiff) - 2.0.1
- [Differ](https://github.com/tonyarnold/Differ) ([Diff.swift](https://github.com/wokalski/Diff.swift)) - 1.4.1
- [DeepDiff](https://github.com/onmyway133/DeepDiff) - 2.2.0
- [Differ](https://github.com/tonyarnold/Differ) ([Diff.swift](https://github.com/wokalski/Diff.swift)) - 1.4.3
- [Dwifft](https://github.com/jflinter/Dwifft) - 0.9
- [Swift.CollectionDifference](https://developer.apple.com/documentation/swift/collectiondifference) Swift 5.1

### Performance Comparison

Benchmark project is [here](https://github.com/ra1028/DifferenceKit/blob/master/Benchmark).
Performance was mesured by code compiled using `Xcode10.2` and `Swift 5.0` with `-O -whole-module-optimization` and run on `iPhoneXs simulator`.
Performance was mesured by code compiled using `Xcode11.1` and `Swift 5.1` with `-O` optimization and run on `iPhone11 Pro simulator`.
Use `Foundation.UUID` as an element of collections.

#### - From 5,000 elements to 1,000 deleted, 1,000 inserted and 200 shuffled

| |Time(sec) |
|:------------|------------:|
|DifferenceKit|`0.0021` |
|RxDataSources|`0.0067` |
|IGListKit |`0.0490` |
|FlexibleDiff |`0.0117` |
|DeepDiff |`0.0263` |
|Differ |`1.2661` |
|Dwifft |`0.4552` |
| |Time(sec) |
|:-------------------------|-------------------------:|
|DifferenceKit |`0.0019` |
|RxDataSources |`0.0074` |
|IGListKit |`0.0346` |
|FlexibleDiff |`0.0161` |
|DeepDiff |`0.0373` |
|Differ |`1.0581` |
|Dwifft |`0.4732` |
|Swift.CollectionDifference|`0.0620` |

#### - From 100,000 elements to 10,000 deleted, 10,000 inserted and 2,000 shuffled

| |Time(sec) |
|:------------|------------:|
|DifferenceKit|`0.0364` |
|RxDataSources|`0.1167` |
|IGListKit |`1.0130` |
|FlexibleDiff |`0.2104` |
|DeepDiff |`0.4180` |
|Differ |`136.8958` |
|Dwifft |`211.4457` |
| |Time(sec) |
|:-------------------------|-------------------------:|
|DifferenceKit |`0.0348` |
|RxDataSources |`0.1024` |
|IGListKit |`0.7002` |
|FlexibleDiff |`0.2189` |
|DeepDiff |`0.5537` |
|Differ |`153.8007` |
|Dwifft |`187.1341` |
|Swift.CollectionDifference|`5.0281` |

### Features Comparison

#### - Algorithm

| |Base algorithm|Order|
|:-------------------------|-------------:|----:|
|DifferenceKit |Heckel |O(N) |
|RxDataSources |Heckel |O(N) |
|FlexibleDiff |Heckel |O(N) |
|IGListKit |Heckel |O(N) |
|DeepDiff |Heckel |O(N) |
|Differ |Myers |O(ND)|
|Dwifft |Myers |O(ND)|
|Swift.CollectionDifference|Myers |O(ND)|

\* [**Heckel algorithm**](https://dl.acm.org/citation.cfm?id=359467)
\* [**Myers algorithm**](http:https://www.xmailserver.org/diff2.pdf)

#### - Supported Collection

| |Linear|Sectioned|Duplicate element/section|
|:------------|:----:|:-------:|:-----------------------:|
|DifferenceKit|✅ |✅ |✅ |
|RxDataSources|❌ |✅ |❌ |
|FlexibleDiff |✅ |✅ |✅ |
|IGListKit |✅ |❌ |✅ |
|DeepDiff |✅ |❌ |✅ |
|Differ |✅ |✅ |✅ |
|Dwifft |✅ |✅ |✅ |
| |Linear|Sectioned|Duplicate element/section|
|:-------------------------|:----:|:-------:|:-----------------------:|
|DifferenceKit |✅ |✅ |✅ |
|RxDataSources |❌ |✅ |❌ |
|FlexibleDiff |✅ |✅ |✅ |
|IGListKit |✅ |❌ |✅ |
|DeepDiff |✅ |❌ |✅ |
|Differ |✅ |✅ |✅ |
|Dwifft |✅ |✅ |✅ |
|Swift.CollectionDifference|✅ |❌ |✅ |

\* **Linear** means 1-dimensional collection
\* **Sectioned** means 2-dimensional collection

#### - Supported Element Diff

| |Delete|Insert|Move|Reload|Move across sections|
|:------------|:----:|:----:|:--:|:----:|:------------------:|
|DifferenceKit|✅ |✅ |✅ |✅ |✅ |
|RxDataSources|✅ |✅ |✅ |✅ |✅ |
|FlexibleDiff |✅ |✅ |✅ |✅ |❌ |
|IGListKit |✅ |✅ |✅ |✅ |❌ |
|DeepDiff |✅ |✅ |✅ |✅ |❌ |
|Differ |✅ |✅ |✅ |❌ |❌ |
|Dwifft |✅ |✅ |❌ |❌ |❌ |
| |Delete|Insert|Move|Reload|Move across sections|
|:-------------------------|:----:|:----:|:--:|:----:|:------------------:|
|DifferenceKit |✅ |✅ |✅ |✅ |✅ |
|RxDataSources |✅ |✅ |✅ |✅ |✅ |
|FlexibleDiff |✅ |✅ |✅ |✅ |❌ |
|IGListKit |✅ |✅ |✅ |✅ |❌ |
|DeepDiff |✅ |✅ |✅ |✅ |❌ |
|Differ |✅ |✅ |✅ |❌ |❌ |
|Dwifft |✅ |✅ |❌ |❌ |❌ |
|Swift.CollectionDifference|✅ |✅ |✅ |❌ |❌ |

#### - Supported Section Diff

| |Delete|Insert|Move|Reload|
|:------------|:----:|:----:|:--:|:----:|
|DifferenceKit|✅ |✅ |✅ |✅ |
|RxDataSources|✅ |✅ |✅ |❌ |
|FlexibleDiff |✅ |✅ |✅ |✅ |
|IGListKit |❌ |❌ |❌ |❌ |
|DeepDiff |❌ |❌ |❌ |❌ |
|Differ |✅ |✅ |✅ |❌ |
|Dwifft |✅ |✅ |❌ |❌ |
| |Delete|Insert|Move|Reload|
|:-------------------------|:----:|:----:|:--:|:----:|
|DifferenceKit |✅ |✅ |✅ |✅ |
|RxDataSources |✅ |✅ |✅ |❌ |
|FlexibleDiff |✅ |✅ |✅ |✅ |
|IGListKit |❌ |❌ |❌ |❌ |
|DeepDiff |❌ |❌ |❌ |❌ |
|Differ |✅ |✅ |✅ |❌ |
|Dwifft |✅ |✅ |❌ |❌ |
|Swift.CollectionDifference|❌ |❌ |❌ |❌ |

---

Expand Down Expand Up @@ -311,6 +333,13 @@ Add the following to your `Cartfile`:
github "ra1028/DifferenceKit"
```

### [Swift Package Manager for Apple platforms](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app)

Select Xcode menu `File > Swift Packages > Add Package Dependency` and enter repository URL with GUI.
```
Repository: https://github.com/ra1028/DifferenceKit
```

### [Swift Package Manager](https://swift.org/package-manager/)

Add the following to the dependencies of your `Package.swift`:
Expand All @@ -334,12 +363,12 @@ DifferenceKit was developed with reference to the following excellent materials

- [A technique for isolating differences between files](https://dl.acm.org/citation.cfm?id=359467) (by [Paul Heckel](https://dl.acm.org/author_page.cfm?id=81100051772))
- [DifferenceAlgorithmComparison](https://github.com/horita-yuya/DifferenceAlgorithmComparison) (by [@horita-yuya](https://github.com/horita-yuya))
- [RxDataSources](https://github.com/RxSwiftCommunity/RxDataSources) (by [@kzaher](https://github.com/kzaher), [RxSwift Community](https://github.com/RxSwiftCommunity))

#### OSS using DifferenceKit
The list of the awesome OSS which uses this library. They also help to understanding how to use DifferenceKit.

- [Carbon](https://github.com/ra1028/Carbon) (by [@ra1028](https://github.com/ra1028))
- [DiffableDataSources](https://github.com/ra1028/DiffableDataSources) (by [@ra1028](https://github.com/ra1028))
- [Rocket.Chat.iOS](https://github.com/RocketChat/Rocket.Chat.iOS) (by [RocketChat](https://github.com/RocketChat))
- [wire-ios](https://github.com/wireapp/wire-ios) (by [Wire Swiss GmbH](https://github.com/wireapp))
- [ReactiveLists](https://github.com/plangrid/ReactiveLists) (by [PlanGrid](https://github.com/plangrid))
Expand All @@ -349,6 +378,7 @@ The list of the awesome OSS which uses this library. They also help to understan
#### Other diffing libraries
I respect and ️❤️ all libraries involved in diffing.

- [RxDataSources](https://github.com/RxSwiftCommunity/RxDataSources) (by [@kzaher](https://github.com/kzaher), [RxSwift Community](https://github.com/RxSwiftCommunity))
- [IGListKit](https://github.com/Instagram/IGListKit) (by [Instagram](https://github.com/Instagram))
- [FlexibleDiff](https://github.com/RACCommunity/FlexibleDiff) (by [@andersio](https://github.com/andersio), [RACCommunity](https://github.com/RACCommunity))
- [DeepDiff](https://github.com/onmyway133/DeepDiff) (by [@onmyway133](https://github.com/onmyway133))
Expand Down
6 changes: 3 additions & 3 deletions docs/Changeset.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="UI Extensions.html">UI Extensions</a>
<a class="nav-group-name-link" href="UI%20Extensions.html">UI Extensions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Extensions/UITableView.html">UITableView</a>
Expand Down Expand Up @@ -216,8 +216,8 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2019 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2019-05-07)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.4</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>&copy; 2019 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2019-10-21)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.11.2</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
Expand Down
10 changes: 5 additions & 5 deletions docs/Diffing.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="UI Extensions.html">UI Extensions</a>
<a class="nav-group-name-link" href="UI%20Extensions.html">UI Extensions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="Extensions/UITableView.html">UITableView</a>
Expand Down Expand Up @@ -161,8 +161,8 @@ <h4>Declaration</h4>
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">@_frozen</span>
<span class="kd">enum</span> <span class="kt">Optional</span><span class="o">&lt;</span><span class="kt">Wrapped</span><span class="o">&gt;</span> <span class="p">:</span> <span class="kt">ExpressibleByNilLiteral</span></code></pre>
<pre class="highlight swift"><code><span class="kd">@frozen</span>
<span class="kd">extension</span> <span class="kt">Optional</span><span class="p">:</span> <span class="kt"><a href="Protocols/ContentEquatable.html">ContentEquatable</a></span> <span class="k">where</span> <span class="kt">Wrapped</span><span class="p">:</span> <span class="kt"><a href="Protocols/ContentEquatable.html">ContentEquatable</a></span></code></pre>

</div>
</div>
Expand Down Expand Up @@ -368,8 +368,8 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2019 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2019-05-07)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.4</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>&copy; 2019 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2019-10-21)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.11.2</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
Expand Down
10 changes: 5 additions & 5 deletions docs/Extensions/Optional.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../UI Extensions.html">UI Extensions</a>
<a class="nav-group-name-link" href="../UI%20Extensions.html">UI Extensions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Extensions/UITableView.html">UITableView</a>
Expand All @@ -107,8 +107,8 @@
<h1>Optional</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">@_frozen</span>
<span class="kd">enum</span> <span class="kt">Optional</span><span class="o">&lt;</span><span class="kt">Wrapped</span><span class="o">&gt;</span> <span class="p">:</span> <span class="kt">ExpressibleByNilLiteral</span></code></pre>
<pre class="highlight swift"><code><span class="kd">@frozen</span>
<span class="kd">extension</span> <span class="kt">Optional</span><span class="p">:</span> <span class="kt"><a href="../Protocols/ContentEquatable.html">ContentEquatable</a></span> <span class="k">where</span> <span class="kt">Wrapped</span><span class="p">:</span> <span class="kt"><a href="../Protocols/ContentEquatable.html">ContentEquatable</a></span></code></pre>

</div>
</div>
Expand Down Expand Up @@ -182,8 +182,8 @@ <h4>Return Value</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2019 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2019-05-07)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.4</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>&copy; 2019 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2019-10-21)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.11.2</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
Expand Down
8 changes: 4 additions & 4 deletions docs/Extensions/UICollectionView.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
</ul>
</li>
<li class="nav-group-name">
<a class="nav-group-name-link" href="../UI Extensions.html">UI Extensions</a>
<a class="nav-group-name-link" href="../UI%20Extensions.html">UI Extensions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a class="nav-group-task-link" href="../Extensions/UITableView.html">UITableView</a>
Expand All @@ -107,7 +107,7 @@
<h1>UICollectionView</h1>
<div class="declaration">
<div class="language">
<pre class="highlight swift"><code><span class="kd">class</span> <span class="kt">UICollectionView</span> <span class="p">:</span> <span class="kt">UIScrollView</span><span class="p">,</span> <span class="kt">UIDataSourceTranslating</span></code></pre>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">extension</span> <span class="kt">UICollectionView</span></code></pre>

</div>
</div>
Expand Down Expand Up @@ -210,8 +210,8 @@ <h4>Parameters</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2019 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2019-05-07)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.4</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>&copy; 2019 <a class="link" href="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/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2019-10-21)</p>
<p>Generated by <a class="link" href="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/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.11.2</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
Expand Down
Loading