-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jack Dermody
committed
Aug 16, 2024
1 parent
4fc4d36
commit 2a09d03
Showing
52 changed files
with
1,316 additions
and
1,070 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using BrightData; | ||
using BrightData.Types; | ||
|
||
namespace Benchmarks | ||
{ | ||
public class SortedArrayBenchmarks | ||
{ | ||
[Params(8, 32, 128, 1024, 32768)] | ||
public int Size { get; set; } | ||
|
||
[Benchmark(Baseline = true)] | ||
public void SortedList() => SortedList(Enumerable.Range(0, Size).Select(x => (float)Size - x).ToArray()); | ||
|
||
[Benchmark] | ||
public void IndexedSortedArray() => IndexedSortedArray(Enumerable.Range(0, Size).Select(x => (float)Size - x).ToArray()); | ||
|
||
public static void SortedList(float[] data) | ||
{ | ||
var list = new SortedList<uint, float>(data.Length); | ||
for(var i = 0U; i < data.Length; i++) | ||
list.Add(i, data[i]); | ||
var search = list.BinarySearch<uint, float>(0); | ||
} | ||
|
||
readonly struct IndexedValue<T>(uint index, T value) : IHaveSingleIndex | ||
{ | ||
public uint Index => index; | ||
public T Value => value; | ||
} | ||
|
||
public static void IndexedSortedArray(float[] data) | ||
{ | ||
var list = new IndexedSortedArray<IndexedValue<float>>(data.Length); | ||
for(var i = 0U; i < data.Length; i++) | ||
list.Add(new IndexedValue<float>(i, data[i])); | ||
var search = list.Find(0); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...perations/Helper/SimpleNumericAnalysis.cs → BrightData/Analysis/SimpleNumericAnalysis.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.