Skip to content

Instantly share code, notes, and snippets.

@ryoppy
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryoppy/777b5dc839863fe743fd to your computer and use it in GitHub Desktop.
Save ryoppy/777b5dc839863fe743fd to your computer and use it in GitHub Desktop.
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
}
[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
@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
}
[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