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

Introduce ArrayRecord #26

Merged
merged 21 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package benchmark
package record4s_arrayrecord

import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.*

@BenchmarkMode(Array(Mode.SingleShotTime))
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Thread)
class CompileCreation {
@Param(Array("1", "50", "100", "150", "200", "250"))
var size: Int = 0

var source: String = ""

var compiler: Compiler = null

@Setup(Level.Iteration)
def setup(): Unit = {
compiler = new Compiler

val fields = (1 to size).map(i => s"f${i} = ${i}").mkString(",")
source = s"""
|import com.github.tarao.record4s.ArrayRecord
|object A {
| val r = ArrayRecord(${fields})
|}
|""".stripMargin
}

@Benchmark
def create_fN =
compiler.compile(source)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package benchmark
package record4s_arrayrecord

import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.*

@BenchmarkMode(Array(Mode.SingleShotTime))
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Thread)
class CompileCreationAndAccess {
@Param(Array("1", "50", "100", "150", "200", "250"))
var size: Int = 0

var source: String = ""

var compiler: Compiler = null

@Setup(Level.Iteration)
def setup(): Unit = {
compiler = new Compiler

val fields = (1 to size).map(i => s"f${i} = ${i}").mkString(",")
val access = (1 to size).map(i => s" r.f${i}").mkString("\n")
source = s"""
|import com.github.tarao.record4s.ArrayRecord
|object A {
| val r = ArrayRecord(${fields})
|${access}
|}
|""".stripMargin
}

@Benchmark
def create_fN =
compiler.compile(source)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package benchmark
package record4s_arrayrecord

import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.*

@BenchmarkMode(Array(Mode.SingleShotTime))
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Thread)
class CompileCreationAndAccessRep {
val repetitions = 10

@Param(Array("1", "50", "100", "150", "200", "250"))
var size: Int = 0

var source: String = ""

var compiler: Compiler = null

@Setup(Level.Iteration)
def setup(): Unit = {
compiler = new Compiler

val fields = (1 to size).map(i => s"f${i} = ${i}").mkString(",")
val access = (1 to repetitions).map(_ => s" r.f${size}").mkString("\n")
source = s"""
|import com.github.tarao.record4s.ArrayRecord
|object A {
| val r = ArrayRecord(${fields})
|${access}
|}
|""".stripMargin
}

@Benchmark
def create_fN =
compiler.compile(source)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package benchmark
package record4s_arrayrecord

import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.*

import com.github.tarao.record4s.ArrayRecord

@BenchmarkMode(Array(Mode.SingleShotTime))
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Thread)
class CompileFieldAccess {
@Param(Array("1", "2", "4", "8", "10", "12", "14", "16", "18", "20", "22", "24", "26", "28", "30", "32"))
var index: Int = 0

var source: String = ""

var compiler: Compiler = null

@Setup(Level.Iteration)
def setup(): Unit = {
compiler = new Compiler

source = s"""
|import benchmark.record4s_arrayrecord.CompileFieldAccess.r
|object A {
| r.f${index}
|}
|""".stripMargin
}

@Benchmark
def access_fN =
compiler.compile(source)
}

object CompileFieldAccess {
val r = ArrayRecord(
f1 = 1,
f2 = 2,
f3 = 3,
f4 = 4,
f5 = 5,
f6 = 6,
f7 = 7,
f8 = 8,
f9 = 9,
f10 = 10,
f11 = 11,
f12 = 12,
f13 = 13,
f14 = 14,
f15 = 15,
f16 = 16,
f17 = 17,
f18 = 18,
f19 = 19,
f20 = 20,
f21 = 21,
f22 = 22,
f23 = 23,
f24 = 24,
f25 = 25,
f26 = 26,
f27 = 27,
f28 = 28,
f29 = 29,
f30 = 30,
f31 = 31,
f32 = 32,
)
}
Loading