Skip to content

Commit

Permalink
Measuring multiple Vector.slice over each other
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed Dec 27, 2024
1 parent 0c41e8d commit 6273121
Showing 1 changed file with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

@BenchmarkMode(Mode.AverageTime)
@Fork(1)
@Warmup(iterations = 3)
@Measurement(iterations = 5)
@Warmup(iterations = 3, time = 3, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 2, timeUnit = TimeUnit.SECONDS)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Benchmark)
public class VectorBenchmarks {
Expand All @@ -35,10 +35,8 @@ public void initializeBenchmark(BenchmarkParams params) throws Exception {
var benchmarkName = SrcUtil.findName(params);
var code =
"""
import Standard.Base.Data.Vector.Builder
import Standard.Base.Data.Vector.Vector
from Standard.Base import all
import Standard.Base.Data.Array_Proxy.Array_Proxy
from Standard.Base.Data.Boolean import False
avg arr =
sum acc i =
Expand All @@ -62,7 +60,16 @@ public void initializeBenchmark(BenchmarkParams params) throws Exception {
to_vector arr = Vector.from_polyglot_array arr
to_array vec = vec.to_array
slice vec = vec.slice
slice n vec start end =
initial = vec.slice start end
complicate round v = if round != 0 then complicate round-1 (v.slice 1 v.length) else
Runtime.assert v==initial
v
if n==0 then initial else
complicate n (0.up_to n).to_vector+initial
fill_proxy proxy vec =
size v =
_ = v
Expand Down Expand Up @@ -91,7 +98,12 @@ public void initializeBenchmark(BenchmarkParams params) throws Exception {
}
case "averageOverSlice":
{
this.arrayOfFibNumbers = getMethod.apply("slice").execute(self, vec, 1, length);
this.arrayOfFibNumbers = getMethod.apply("slice").execute(self, 0, vec, 1, length);
break;
}
case "averageOverSliceWrapped":
{
this.arrayOfFibNumbers = getMethod.apply("slice").execute(self, 10, vec, 1, length);
break;
}
case "averageOverArray":
Expand Down Expand Up @@ -154,6 +166,11 @@ public void averageOverSlice(Blackhole matter) {
performBenchmark(matter);
}

@Benchmark
public void averageOverSliceWrapped(Blackhole matter) {
performBenchmark(matter);
}

@Benchmark
public void averageOverPolyglotVector(Blackhole matter) {
performBenchmark(matter);
Expand Down

0 comments on commit 6273121

Please sign in to comment.