Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cuckoo filter #665

Open
wants to merge 20 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.twitter.algebird
package benchmark

import com.twitter.algebird.benchmark.CuckooFilterBenchmarkQuery.CuckooFilterState
import org.openjdk.jmh.annotations._

object CuckooFilterBenchmarkQuery {

@State(Scope.Benchmark)
class CuckooFilterState {

@Param(Array("100", "1000", "10000"))
var nbrOfElements: Int = 0

@Param(Array("100", "300"))
var bucketNumber: Int = 0

@Param(Array("10", "50"))
var fingerprintBucket: Int = 0

var cf: CF[String] = _

@Setup(Level.Trial)
def setup(): Unit = {
val randomStrings =
CuckooFilterCreateBenchmark.createRandomString(nbrOfElements, 10)
cf = CuckooFilter[String](fingerprintBucket, bucketNumber)
.create(randomStrings: _*)
}
}
}

class CuckooFilterBenchmarkQuery {

@Benchmark
def queryCuckooFilter(cuckooFilterState: CuckooFilterState): Boolean =
cuckooFilterState.cf.lookup("1")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.twitter.algebird
package benchmark

import com.twitter.algebird.benchmark.CuckooFilterCreateBenchmark.CuckooFilterState
import org.openjdk.jmh.annotations._

import scala.util.Random

object CuckooFilterCreateBenchmark {
def createRandomString(nbString: Int, sizeStr: Int): Seq[String] =
Seq.fill(nbString)(Random.nextString(sizeStr))

@State(Scope.Benchmark)
class CuckooFilterState() {

@Param(Array("100", "1000", "10000"))
var nbrOfElements: Int = 0

@Param(Array("100", "300"))
var bucketNumber: Int = 0

@Param(Array("10", "50"))
var fingerprintBucket: Int = 0

var randomStrings: Seq[String] = _

@Setup(Level.Trial)
def setup(): Unit =
randomStrings = createRandomString(nbrOfElements, 10)
}

}

class CuckooFilterCreateBenchmark {
@Benchmark
def createCuckooFilter(cuckooFilterState: CuckooFilterState): CF[String] = {
val cfMonoid = CuckooFilter[String](cuckooFilterState.fingerprintBucket, cuckooFilterState.bucketNumber)
val cf = cfMonoid.create(cuckooFilterState.randomStrings: _*)
cf
}
}
Loading