Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
psfinaki committed Feb 12, 2024
1 parent 7329ee1 commit 7864404
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions tests/benchmarks/CompiledCodeBenchmarks/MicroPerf/Equality.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,56 @@ type SomeStruct =

type EqualityBenchmarks() =

let array = Array.init 1000 id
let list = List.init 1000 id
let seq = Seq.init 1000 id

[<Benchmark>]
member _.ArrayCountBy() =
Array.init 1000 id
array
|> Array.countBy (fun n -> SomeStruct(n % 7))

[<Benchmark>]
member _.ArrayGroupBy() =
Array.init 1000 id
array
|> Array.groupBy (fun n -> SomeStruct(n % 7))

[<Benchmark>]
member _.ArrayDistinct() =
Array.init 1000 id
array
|> Array.map (fun n -> SomeStruct(n % 7))
|> Array.distinct

[<Benchmark>]
member _.ArrayDistinctBy() =
Array.init 1000 id
array
|> Array.distinctBy (fun n -> SomeStruct(n % 7))

[<Benchmark>]
member _.ArrayExcept() =
Array.init 1000 id
array
|> Array.map SomeStruct
|> Array.except ([| SomeStruct 42 |])

[<Benchmark>]
member _.ListCountBy() =
List.init 1000 id
list
|> List.countBy (fun n -> SomeStruct(n % 7))

[<Benchmark>]
member _.ListGroupBy() =
List.init 1000 id
list
|> List.groupBy (fun n -> SomeStruct(n % 7))

[<Benchmark>]
member _.ListDistinct() =
List.init 1000 id
list
|> List.map (fun n -> SomeStruct(n % 7))
|> List.distinct

[<Benchmark>]
member _.ListDistinctBy() =
List.init 1000 id
list
|> List.distinctBy (fun n -> SomeStruct(n % 7))

[<Benchmark>]
Expand All @@ -65,32 +69,32 @@ type EqualityBenchmarks() =

[<Benchmark>]
member _.SeqCountBy() =
Seq.init 1000 id
seq
|> Seq.countBy (fun n -> SomeStruct(n % 7))
|> Seq.last

[<Benchmark>]
member _.SeqGroupBy() =
Seq.init 1000 id
seq
|> Seq.groupBy (fun n -> SomeStruct(n % 7))
|> Seq.last

[<Benchmark>]
member _.SeqDistinct() =
Seq.init 1000 id
seq
|> Seq.map (fun n -> SomeStruct(n % 7))
|> Seq.distinct
|> Seq.last

[<Benchmark>]
member _.SeqDistinctBy() =
Seq.init 1000 id
seq
|> Seq.distinctBy (fun n -> SomeStruct(n % 7))
|> Seq.last

[<Benchmark>]
member _.SeqExcept() =
Seq.init 1000 id
seq
|> Seq.map SomeStruct
|> Seq.except ([| SomeStruct 42 |])
|> Seq.last

0 comments on commit 7864404

Please sign in to comment.