-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
494 additions
and
233 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
38 changes: 38 additions & 0 deletions
38
algebird-caliper/src/main/scala/com/twitter/algebird/HllBatchCreateBenchmark.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,38 @@ | ||
package com.twitter.algebird.caliper | ||
|
||
import com.google.caliper.{Param, SimpleBenchmark} | ||
import com.twitter.algebird.HyperLogLogMonoid | ||
|
||
import java.nio.ByteBuffer | ||
|
||
class HllBatchCreateBenchmark extends SimpleBenchmark { | ||
@Param(Array("5", "10", "17", "25")) | ||
val bits: Int = 0 | ||
|
||
@Param(Array("10", "20", "30")) | ||
val max: Long = 0 | ||
|
||
var set: Set[Long] = _ | ||
|
||
/* Don't use twitter bijection to reduce dependencies on other projects */ | ||
implicit def injection(value: Long) = { | ||
val size = 8 | ||
val buf = ByteBuffer.allocate(size) | ||
buf.putLong(value) | ||
buf.array | ||
} | ||
|
||
override def setUp { | ||
set = (0L until max).toSet | ||
} | ||
|
||
def timeBatchCreate(reps: Int): Int = { | ||
val hllMonoid = new HyperLogLogMonoid(bits) | ||
var dummy = 0 | ||
while (dummy < reps) { | ||
val hll = hllMonoid.batchCreate(set)(injection) | ||
dummy += 1 | ||
} | ||
dummy | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
algebird-caliper/src/main/scala/com/twitter/algebird/Runner.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,23 @@ | ||
package com.twiter.algebird.caliper | ||
|
||
/** Adapted from @link https://github.com/sirthias/scala-benchmarking-template/blob/master/src/main/scala/org/example/Runner.scala | ||
*/ | ||
import com.google.caliper.{Benchmark, Runner => CaliperRunner} | ||
import com.google.common.collect.ObjectArrays.concat | ||
|
||
import java.io.PrintWriter | ||
|
||
object Runner { | ||
|
||
import com.twitter.algebird.caliper._ | ||
|
||
def main(args: Array[String]) { | ||
val outWriter = new PrintWriter(System.out, true) | ||
val errWriter = new PrintWriter(System.err, true) | ||
/* We should probably call to the Caliper command line | ||
tool if we want to scale up? */ | ||
CaliperRunner.main(classOf[HllBatchCreateBenchmark], args) | ||
} | ||
|
||
} | ||
|
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
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
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.