-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support for running jmh with bleep. add first
map
benchmark.
Towards #1
- Loading branch information
1 parent
99fd339
commit f252dbd
Showing
6 changed files
with
108 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package farray | ||
|
||
import org.openjdk.jmh.annotations._ | ||
import scala.collection.immutable.BitSet | ||
import java.util.concurrent.TimeUnit | ||
import org.openjdk.jmh.annotations.Benchmark | ||
import scala.collection.immutable.BitSet | ||
|
||
@State(Scope.Thread) | ||
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) | ||
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) | ||
@Fork( | ||
value = 1, | ||
jvmArgs = Array( | ||
"-server", | ||
"-Xms2g", | ||
"-Xmx2g", | ||
"-XX:NewSize=1g", | ||
"-XX:MaxNewSize=1g", | ||
"-XX:InitialCodeCacheSize=512m", | ||
"-XX:ReservedCodeCacheSize=512m", | ||
"-XX:+UseParallelGC", | ||
"-XX:-UseAdaptiveSizePolicy", | ||
"-XX:MaxInlineLevel=20", | ||
"-XX:InlineSmallCode=1500", | ||
"-XX:+AlwaysPreTouch", | ||
"-XX:+UseNUMA", | ||
"-XX:-UseAdaptiveNUMAChunkSizing" | ||
) | ||
) | ||
@BenchmarkMode(Array(Mode.Throughput)) | ||
@OutputTimeUnit(TimeUnit.SECONDS) | ||
abstract class CommonParams |
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,28 @@ | ||
package farray | ||
|
||
import bleep.* | ||
import bleep.internal.FileUtils | ||
import org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator | ||
|
||
import java.io.File | ||
import java.nio.file.{Files, Path} | ||
import scala.collection.Seq | ||
|
||
object GenJmh extends BleepCodegenScript("GenJmh") { | ||
def run(started: Started, commands: Commands, benchmarksRunnerProject: model.CrossProjectName, args: List[String]): Unit = { | ||
val benchmarksProject = model.CrossProjectName(model.ProjectName("benchmarks"), None) | ||
|
||
val paths = started.projectPaths(benchmarksRunnerProject) | ||
val sourceDir = paths.sourcesDirs.generated | ||
val resourceDir = paths.resourcesDirs.generated | ||
val classesDir = started.projectPaths(benchmarksProject).classes | ||
|
||
// rebuild everything | ||
FileUtils.deleteDirectory(sourceDir) | ||
Files.createDirectories(sourceDir) | ||
FileUtils.deleteDirectory(resourceDir) | ||
Files.createDirectories(resourceDir) | ||
|
||
JmhBytecodeGenerator.main(Array(classesDir.toString, sourceDir.toString, resourceDir.toString, "default")) | ||
} | ||
} |
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,19 @@ | ||
package farray | ||
|
||
import org.openjdk.jmh.annotations.{Param, Setup} | ||
|
||
abstract class Inputs extends CommonParams { | ||
var listInput: List[String] = _ | ||
var farrayInput: FArray[String] = _ | ||
var iarrayInput: IArray[String] = _ | ||
|
||
@Param(Array("1", "10", "100", "1000", "10000", "100000", "1000000")) | ||
var size: Int = 1000 | ||
|
||
@Setup | ||
def setup(): Unit = { | ||
listInput = List.tabulate(size)(_.toString) | ||
farrayInput = FArray.tabulate(size)(_.toString) | ||
iarrayInput = IArray.tabulate(size)(_.toString) | ||
} | ||
} |
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,9 @@ | ||
package farray | ||
|
||
import org.openjdk.jmh.annotations.Benchmark | ||
|
||
class MapBenchmark extends Inputs { | ||
@Benchmark def list(): List[String] = listInput.map(x => x + x) | ||
@Benchmark def farray(): FArray[String] = farrayInput.map(x => x + x) | ||
@Benchmark def iarray(): IArray[String] = iarrayInput.map(x => x + x) | ||
} |
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