-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'version-1.5.x' into NODE-2496
- Loading branch information
Showing
39 changed files
with
700 additions
and
248 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
75 changes: 75 additions & 0 deletions
75
benchmark/src/test/scala/com/wavesplatform/lang/v1/ListReplaceByIndexBenchmark.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,75 @@ | ||
package com.wavesplatform.lang.v1 | ||
|
||
import com.wavesplatform.common.utils.EitherExt2 | ||
import com.wavesplatform.lang.Common | ||
import com.wavesplatform.lang.directives.values.StdLibVersion | ||
import com.wavesplatform.lang.v1.FunctionHeader.Native | ||
import com.wavesplatform.lang.v1.compiler.Terms.* | ||
import com.wavesplatform.lang.v1.evaluator.FunctionIds.REPLACE_BY_INDEX_OF_LIST | ||
import com.wavesplatform.lang.v1.evaluator.ctx.impl.PureContext | ||
import com.wavesplatform.lang.v1.traits.Environment | ||
import org.openjdk.jmh.annotations.* | ||
import org.openjdk.jmh.infra.Blackhole | ||
|
||
import scala.concurrent.duration.{MICROSECONDS, SECONDS} | ||
|
||
@OutputTimeUnit(MICROSECONDS) | ||
@BenchmarkMode(Array(Mode.AverageTime)) | ||
@Threads(1) | ||
@Fork(1) | ||
@Warmup(iterations = 10, time = 1, timeUnit = SECONDS) | ||
@Measurement(iterations = 10, time = 1, timeUnit = SECONDS) | ||
class ListReplaceByIndexBenchmark { | ||
@Benchmark | ||
def listReplaceFirstByIndex(st: ListReplaceByIndexSt, bh: Blackhole): Unit = | ||
bh.consume(eval(st.ctx, st.replaceFirst)) | ||
|
||
@Benchmark | ||
def listReplaceMiddleByIndex(st: ListReplaceByIndexSt, bh: Blackhole): Unit = | ||
bh.consume(eval(st.ctx, st.replaceMiddle)) | ||
|
||
@Benchmark | ||
def listReplaceLastByIndex(st: ListReplaceByIndexSt, bh: Blackhole): Unit = | ||
bh.consume(eval(st.ctx, st.replaceLast)) | ||
} | ||
|
||
@State(Scope.Benchmark) | ||
class ListReplaceByIndexSt { | ||
val ctx = | ||
PureContext | ||
.build(StdLibVersion.VersionDic.all.max, useNewPowPrecision = true) | ||
.withEnvironment[Environment] | ||
.evaluationContext(Common.emptyBlockchainEnvironment()) | ||
|
||
val list = ARR(Vector.fill(1000)(CONST_LONG(Long.MaxValue)), limited = true).explicitGet() | ||
|
||
val replaceFirst = | ||
FUNCTION_CALL( | ||
Native(REPLACE_BY_INDEX_OF_LIST), | ||
List( | ||
list, | ||
CONST_LONG(0), | ||
CONST_LONG(777) | ||
) | ||
) | ||
|
||
val replaceMiddle = | ||
FUNCTION_CALL( | ||
Native(REPLACE_BY_INDEX_OF_LIST), | ||
List( | ||
list, | ||
CONST_LONG(500), | ||
CONST_LONG(777) | ||
) | ||
) | ||
|
||
val replaceLast = | ||
FUNCTION_CALL( | ||
Native(REPLACE_BY_INDEX_OF_LIST), | ||
List( | ||
list, | ||
CONST_LONG(999), | ||
CONST_LONG(777) | ||
) | ||
) | ||
} |
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
51 changes: 51 additions & 0 deletions
51
benchmark/src/test/scala/com/wavesplatform/state/CalculateDelayBenchmark.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,51 @@ | ||
package com.wavesplatform.state | ||
|
||
import com.wavesplatform.common.state.ByteStr | ||
import org.openjdk.jmh.annotations.* | ||
import org.openjdk.jmh.infra.Blackhole | ||
|
||
import java.util.concurrent.TimeUnit | ||
|
||
/* | ||
[info] Benchmark (configFile) Mode Cnt Score Error Units | ||
[info] CalculateDelayBenchmark.calculateDelay1 waves.conf avgt 10 1,616 ± 0,244 us/op | ||
[info] CalculateDelayBenchmark.calculateDelay2 waves.conf avgt 10 1,671 ± 0,073 us/op | ||
[info] CalculateDelayBenchmark.calculateDelay3 waves.conf avgt 10 1,688 ± 0,228 us/op | ||
[info] CalculateDelayBenchmark.calculateDelay4 waves.conf avgt 10 1,656 ± 0,020 us/op | ||
*/ | ||
|
||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
@BenchmarkMode(Array(Mode.AverageTime)) | ||
@Threads(1) | ||
@Fork(1) | ||
@Warmup(iterations = 5, time = 1) | ||
@Measurement(iterations = 10, time = 1) | ||
class CalculateDelayBenchmark { | ||
import CalculateDelayBenchmark.* | ||
|
||
@Benchmark | ||
def calculateDelay1(bh: Blackhole, st: St): Unit = | ||
bh.consume(st.environment.calculateDelay(ByteStr.empty, 0, ByteStr.empty, 0)) | ||
|
||
@Benchmark | ||
def calculateDelay2(bh: Blackhole, st: St): Unit = | ||
bh.consume( | ||
st.environment.calculateDelay(ByteStr.fill(96)(127), Long.MaxValue, ByteStr.fill(26)(127), Long.MaxValue) | ||
) | ||
|
||
@Benchmark | ||
def calculateDelay3(bh: Blackhole, st: St): Unit = | ||
bh.consume( | ||
st.environment.calculateDelay(ByteStr.fill(96)(-128), Long.MinValue, ByteStr.fill(26)(-128), Long.MinValue) | ||
) | ||
|
||
@Benchmark | ||
def calculateDelay4(bh: Blackhole, st: St): Unit = | ||
bh.consume( | ||
st.environment.calculateDelay(ByteStr.fill(32)(32), 123456, ByteStr.fill(26)(32), 100_000_000) | ||
) | ||
} | ||
|
||
object CalculateDelayBenchmark { | ||
class St extends DBState {} | ||
} |
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.