-
Notifications
You must be signed in to change notification settings - Fork 421
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/version-1.5.x' into node-2611-fo…
…rbidden-ride-v1-v3
- Loading branch information
Showing
193 changed files
with
4,086 additions
and
2,984 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
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
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.