bitfieldtracking's Issues
[Possible typo] Nodes and vertices?
Hi Matthew,
Great blog post, but there's one thing in it that is confusing me a bit. In a couple of places you talk about only having to deal with "20 nodes and 30 vertices". Is that a typo? My understanding is that vertices are the directed-graph equivalent of nodes in an undirected graph, so I'm not sure what you are meaning by that statement if it isn't a typo ๐
Anyway, thanks for the post! ๐
Results from 3 Intel machines
Hi Matthew,
came here to suggest trying BitArray only to find you've already on it. I've run the benchmark on 3 Intel machines.
2015 iMac results:
BenchmarkDotNet=v0.13.1, OS=macOS Monterey 12.1 (21C52) [Darwin 21.2.0]
Intel Core i7-6700K CPU 4.00GHz (Skylake), 1 CPU, 8 logical and 4 physical cores
.NET SDK=6.0.101
[Host] : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT DEBUG
DefaultJob : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT
| Method | Mean | Error | StdDev | Gen 0 | Allocated |
|----------------- |-----------:|----------:|----------:|-----------:|--------------:|
| SetTracker | 150.177 ms | 0.8721 ms | 0.7731 ms | 54000.0000 | 226,813,220 B |
| HashSetTracker | 16.841 ms | 0.1011 ms | 0.0945 ms | - | 2,818 B |
| BoolArrayTracker | 5.547 ms | 0.1101 ms | 0.1224 ms | - | 86 B |
| BitArrayTracker | 6.019 ms | 0.1095 ms | 0.1024 ms | - | 70 B |
| SpanTracker | 3.746 ms | 0.0355 ms | 0.0332 ms | - | 3 B |
| Int64Tracker | 4.929 ms | 0.0572 ms | 0.0536 ms | - | 6 B |
Results from a 2019 MacBook Pro:
// * Summary *
BenchmarkDotNet=v0.13.1, OS=macOS Monterey 12.1 (21C52) [Darwin 21.2.0]
Intel Core i9-9880H CPU 2.30GHz, 1 CPU, 16 logical and 8 physical cores
.NET SDK=6.0.102
[Host] : .NET 6.0.2 (6.0.222.6406), X64 RyuJIT DEBUG
DefaultJob : .NET 6.0.2 (6.0.222.6406), X64 RyuJIT
| Method | Mean | Error | StdDev | Gen 0 | Allocated |
|----------------- |-----------:|----------:|----------:|-----------:|--------------:|
| SetTracker | 144.263 ms | 2.5894 ms | 2.1623 ms | 27000.0000 | 226,817,992 B |
| HashSetTracker | 15.218 ms | 0.2657 ms | 0.2355 ms | - | 2,805 B |
| BoolArrayTracker | 4.916 ms | 0.0512 ms | 0.0479 ms | - | 86 B |
| BitArrayTracker | 5.414 ms | 0.0708 ms | 0.0662 ms | - | 70 B |
| SpanTracker | 3.317 ms | 0.0344 ms | 0.0305 ms | - | 3 B |
| Int64Tracker | 4.311 ms | 0.0722 ms | 0.0675 ms | - | 6 B |
Windows custom desktop:
// * Summary *
BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19043.1526 (21H1/May2021Update)
Intel Core i7-7700K CPU 4.20GHz (Kaby Lake), 1 CPU, 8 logical and 4 physical cores
.NET SDK=6.0.101
[Host] : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT DEBUG
DefaultJob : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT
| Method | Mean | Error | StdDev | Gen 0 | Allocated |
|----------------- |-----------:|----------:|----------:|-----------:|--------------:|
| SetTracker | 125.239 ms | 2.0144 ms | 1.8842 ms | 54000.0000 | 226,813,932 B |
| HashSetTracker | 14.923 ms | 0.2650 ms | 0.2721 ms | - | 2,800 B |
| BoolArrayTracker | 4.407 ms | 0.0529 ms | 0.0495 ms | - | 84 B |
| BitArrayTracker | 4.954 ms | 0.0201 ms | 0.0188 ms | - | 68 B |
| SpanTracker | 2.865 ms | 0.0126 ms | 0.0118 ms | - | 2 B |
| Int64Tracker | 3.702 ms | 0.0153 ms | 0.0143 ms | - | 2 B |
On Intel machines, SpanTracker seems consistently the fastest choice. Weird the allocation numbers are different than what you're seeing on AMD, but I guess it all comes down to the low level chip features.
Just for completeness, System.Collections.BitArray
Not limited in index size, unlike Int64Tracker,
Slower than Array. but smaller (especially for large index size).
[<Benchmark>]
member _.BitArrayTracker () =
let mutable tracker = System.Collections.BitArray(indexRange)
for i = 0 to testIndexes.Length - 1 do
let testIndex = testIndexes[i]
if tracker[testIndex] then
// Real world we would do work here and then flip the case
tracker[testIndex] <- false
else
tracker[testIndex] <- true
tracker
Results on my machine
BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19044.1503 (21H2)
Intel Core i3-5157U CPU 2.50GHz (Broadwell), 1 CPU, 4 logical and 2 physical cores
.NET SDK=6.0.101
[Host] : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT DEBUG
DefaultJob : .NET 6.0.1 (6.0.121.56705), X64 RyuJIT
| Method | Mean | Error | StdDev | Gen 0 | Allocated |
|----------------- |-----------:|----------:|----------:|------------:|--------------:|
| SetTracker | 233.042 ms | 1.5436 ms | 1.4439 ms | 144333.3333 | 226,813,221 B |
| HashSetTracker | 28.022 ms | 0.0929 ms | 0.0725 ms | - | 2,808 B |
| BoolArrayTracker | 7.633 ms | 0.0235 ms | 0.0220 ms | - | 84 B |
| Int64Tracker | 6.411 ms | 0.0196 ms | 0.0173 ms | - | 6 B |
| BitArrayTracker | 8.763 ms | 0.0307 ms | 0.0256 ms | - | 72 B |
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.