Created
September 25, 2011 02:16
-
-
Save derekjw/1240127 to your computer and use it in GitHub Desktop.
Fix for scala-redis Scatter/Gather benchmark
This file contains hidden or 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
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