-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Arrange benchmarks to avoid using unnecessary parameters
- Loading branch information
Showing
4 changed files
with
56 additions
and
16 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
24 changes: 24 additions & 0 deletions
24
lib/src/jmh/java/benchmark/EmojiManagerAliasBenchmark.java
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,24 @@ | ||
package benchmark; | ||
|
||
import net.fellbaum.jemoji.Emoji; | ||
import net.fellbaum.jemoji.EmojiManager; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.Param; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.State; | ||
|
||
import java.util.Optional; | ||
|
||
@State(Scope.Benchmark) | ||
public class EmojiManagerAliasBenchmark { | ||
|
||
@Param({":+1:", "nope"}) | ||
private String alias; | ||
|
||
@Benchmark | ||
//@BenchmarkMode(Mode.AverageTime) | ||
//@Warmup(iterations = 1) | ||
public Optional<Emoji> getByAlias() { | ||
return EmojiManager.getByAlias(alias); | ||
} | ||
} |
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
27 changes: 27 additions & 0 deletions
27
lib/src/jmh/java/benchmark/excluded/CodePointBenchmark.java
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,27 @@ | ||
package benchmark.excluded; | ||
|
||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.Param; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.State; | ||
|
||
@State(Scope.Benchmark) | ||
public class CodePointBenchmark { | ||
@Param("\uD83D\uDC4D\uD83C\uDFFC") | ||
private String alias; | ||
|
||
@Benchmark | ||
public int codePointArrayLength() { | ||
return alias.codePoints().toArray().length; | ||
} | ||
|
||
@Benchmark | ||
public long codePointStreamCount() { | ||
return alias.codePoints().count(); | ||
} | ||
|
||
@Benchmark | ||
public int codePointCount() { | ||
return alias.codePointCount(0, alias.length()); | ||
} | ||
} |