Last active
August 29, 2015 14:13
-
-
Save ryoppy/777b5dc839863fe743fd to your computer and use it in GitHub Desktop.
scala - 重複除去 ref: http://qiita.com/ryoppy@github/items/8fb6e77898a8f9258126
This file contains hidden or 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
class Bench { | |
@Benchmark | |
def set2seq(): Unit = (1 to 100).combinations(2).toList.flatten.toSet.toSeq | |
@Benchmark | |
def distinct(): Unit = (1 to 100).combinations(2).toList.flatten.distinct | |
} |
This file contains hidden or 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
[info] Benchmark Mode Samples Score Score error Units | |
[info] f.Bench.set2seq thrpt 3 90.893 495.577 ops/s | |
[info] f.Bench.distinct thrpt 3 109.927 75.496 ops/s |
This file contains hidden or 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
@State(Scope.Thread) | |
class Bench { | |
val list: Seq[Int] = (1 to 100).combinations(2).toList.flatten | |
@Benchmark | |
def set2seq(): Unit = list.toSet.toSeq | |
@Benchmark | |
def distinct(): Unit = list.distinct | |
} |
This file contains hidden or 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
[info] Benchmark Mode Samples Score Score error Units | |
[info] f.Bench.distinct thrpt 3 13111.451 3086.943 ops/s | |
[info] f.Bench.set2seq thrpt 3 5717.012 4046.475 ops/s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment