-
Notifications
You must be signed in to change notification settings - Fork 422
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
Showing
19 changed files
with
399 additions
and
241 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
benchmark/src/test/scala/com/wavesplatform/lang/v1/FunctionCallCopyBenchmark.scala
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,71 @@ | ||
package com.wavesplatform.lang.v1 | ||
|
||
import com.wavesplatform.common.utils.EitherExt2 | ||
import com.wavesplatform.lang.v1.FunctionCallCopyBenchmark.FuncCallSt | ||
import com.wavesplatform.lang.v1.compiler.Terms.* | ||
import org.openjdk.jmh.annotations.* | ||
import org.openjdk.jmh.infra.Blackhole | ||
|
||
import java.util.concurrent.TimeUnit | ||
|
||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
@BenchmarkMode(Array(Mode.AverageTime)) | ||
@Threads(1) | ||
@Fork(1) | ||
@Warmup(iterations = 10, time = 1) | ||
@Measurement(iterations = 10, time = 1) | ||
class FunctionCallCopyBenchmark { | ||
@Benchmark | ||
def twoLevelsDeep(st: FuncCallSt, bh: Blackhole): Unit = | ||
bh.consume(st.twoLevelsDeep.deepCopy.value) | ||
|
||
@Benchmark | ||
def threeLevelsDeep(st: FuncCallSt, bh: Blackhole): Unit = | ||
bh.consume(st.threeLevelsDeep.deepCopy.value) | ||
|
||
@Benchmark | ||
def fourLevelsDeep(st: FuncCallSt, bh: Blackhole): Unit = | ||
bh.consume(st.fourLevelsDeep.deepCopy.value) | ||
} | ||
|
||
object FunctionCallCopyBenchmark { | ||
|
||
@State(Scope.Benchmark) | ||
class FuncCallSt { | ||
val simpleCall: FUNCTION_CALL = FUNCTION_CALL( | ||
FunctionHeader.User("fooBar"), | ||
List( | ||
CONST_STRING("foobar").explicitGet(), | ||
CONST_LONG(1000L), | ||
CONST_BOOLEAN(false) | ||
) | ||
) | ||
|
||
val twoLevelsDeep: FUNCTION_CALL = FUNCTION_CALL( | ||
FunctionHeader.User("fooBar"), | ||
List( | ||
FUNCTION_CALL(FunctionHeader.User("fooBar"), List.fill(3)(simpleCall)), | ||
FUNCTION_CALL(FunctionHeader.User("fooBar"), List.fill(3)(simpleCall)), | ||
FUNCTION_CALL(FunctionHeader.User("fooBar"), List.fill(3)(simpleCall)), | ||
) | ||
) | ||
|
||
val threeLevelsDeep: FUNCTION_CALL = FUNCTION_CALL( | ||
FunctionHeader.User("fooBar"), | ||
List( | ||
FUNCTION_CALL(FunctionHeader.User("fooBar"), List.fill(3)(twoLevelsDeep)), | ||
FUNCTION_CALL(FunctionHeader.User("fooBar"), List.fill(3)(twoLevelsDeep)), | ||
FUNCTION_CALL(FunctionHeader.User("fooBar"), List.fill(3)(twoLevelsDeep)), | ||
) | ||
) | ||
|
||
val fourLevelsDeep: FUNCTION_CALL = FUNCTION_CALL( | ||
FunctionHeader.User("fooBar"), | ||
List( | ||
FUNCTION_CALL(FunctionHeader.User("fooBar"), List.fill(3)(threeLevelsDeep)), | ||
FUNCTION_CALL(FunctionHeader.User("fooBar"), List.fill(3)(threeLevelsDeep)), | ||
FUNCTION_CALL(FunctionHeader.User("fooBar"), List.fill(3)(threeLevelsDeep)), | ||
) | ||
) | ||
} | ||
} |
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
Oops, something went wrong.