Skip to content

Instantly share code, notes, and snippets.

@derekjw
Created September 25, 2011 02:16
Show Gist options
  • Save derekjw/1240127 to your computer and use it in GitHub Desktop.
Save derekjw/1240127 to your computer and use it in GitHub Desktop.
Fix for scala-redis Scatter/Gather benchmark
diff --git a/src/test/scala/com/redis/Patterns.scala b/src/test/scala/com/redis/Patterns.scala
index 0870ca0..03d9b8f 100644
--- a/src/test/scala/com/redis/Patterns.scala
+++ b/src/test/scala/com/redis/Patterns.scala
@@ -55,7 +55,7 @@ object Patterns {
// entering gather phase
val allSum =
- allPushes onSuccess {result =>
+ allPushes flatMap {result =>
// pop from all 100 lists in parallel
val futurePops: Seq[Future[Int]] =
@@ -69,7 +69,7 @@ object Patterns {
val allPops: Future[Seq[Int]] = Future.collect(futurePops)
// compute sum of all integers
- allPops onSuccess {members => members.sum}
+ allPops map {members => members.sum}
}
allSum.apply
}
diff --git a/src/test/scala/com/redis/PatternsSpec.scala b/src/test/scala/com/redis/PatternsSpec.scala
index c108d6a..b6704f5 100644
--- a/src/test/scala/com/redis/PatternsSpec.scala
+++ b/src/test/scala/com/redis/PatternsSpec.scala
@@ -31,10 +31,11 @@ class PatternsSpec extends Spec
def runScatterGather(opsPerRun: Int) = {
val start = System.nanoTime
- scatterGatherWithList(opsPerRun)
+ val result = scatterGatherWithList(opsPerRun)
val elapsed: Double = (System.nanoTime - start) / 1000000000.0
val opsPerSec: Double = (100 * opsPerRun * 2) / elapsed
println("Operations per run: " + opsPerRun * 100 * 2 + " elapsed: " + elapsed + " ops per second: " + opsPerSec)
+ assert(result == (1 to opsPerRun).sum * 100)
}
describe("scatter/gather with list test 1") {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment