-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add benchmark results
- Loading branch information
Showing
7 changed files
with
78 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
# indexVerse | ||
Simple inverted index generator in Scala | ||
|
||
|
||
## Benchmarking results | ||
|
||
[info] Benchmark (numThreads) Mode Cnt Score Error Units | ||
[info] BenchmarkIndex.testIndexing 1 avgt 6 4.300 ± 0.760 s/op | ||
[info] BenchmarkIndex.testIndexing 2 avgt 6 2.177 ± 0.176 s/op | ||
[info] BenchmarkIndex.testIndexing 4 avgt 6 1.249 ± 0.058 s/op | ||
[info] BenchmarkIndex.testIndexing 8 avgt 6 0.693 ± 0.019 s/op |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3") |
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
28 changes: 28 additions & 0 deletions
28
src/main/scala/com/gmail/rayanral/index/benchmark/BenchmarkIndex.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,28 @@ | ||
package com.gmail.rayanral.index.benchmark | ||
|
||
import com.gmail.rayanral.IndexGenerationRunner | ||
import com.gmail.rayanral.index.util.Config | ||
import org.openjdk.jmh.annotations._ | ||
import org.openjdk.jmh.infra.Blackhole | ||
|
||
@BenchmarkMode(Array(Mode.AverageTime)) | ||
@Fork(value = 2) | ||
@Warmup(iterations = 1) | ||
@Measurement(iterations = 3) | ||
@State(Scope.Benchmark) | ||
class BenchmarkIndex { | ||
|
||
@Param(Array("1", "2", "4", "8")) | ||
var numThreads = 0 | ||
|
||
@Benchmark | ||
def testIndexing(blackHole: Blackhole): Unit = { | ||
val index = IndexGenerationRunner.runIndexer( | ||
inputDir = Config.DEFAULT_INPUT_DIR, | ||
extension = Config.DEFAULT_EXTENSION, | ||
numThreads = numThreads | ||
) | ||
blackHole.consume(index) | ||
} | ||
|
||
} |
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
23 changes: 23 additions & 0 deletions
23
src/test/scala/com/gmail/rayanral/index/model/InvertedIndexTest.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.gmail.rayanral.index.model | ||
|
||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers._ | ||
|
||
class InvertedIndexTest extends AnyFlatSpec { | ||
|
||
"invertedIndex" should "add a word" in { | ||
val index = new InvertedIndex() | ||
val wordToAdd = "word" | ||
index.add(wordToAdd, "file") | ||
index.getTopWords(1).map(_._1) should contain(wordToAdd) | ||
} | ||
|
||
"invertedIndex" should "add several words with correct counts" in { | ||
val index = new InvertedIndex() | ||
val duplicate = "word" | ||
val wordsToAdd = List(duplicate, duplicate, "anotherWord") | ||
wordsToAdd.foreach(index.add(_, "file")) | ||
index.getTopWords(1).head._1 shouldBe duplicate | ||
} | ||
|
||
} |