Skip to content

Instantly share code, notes, and snippets.

@ngocdaothanh
Last active December 27, 2015 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngocdaothanh/7315180 to your computer and use it in GitHub Desktop.
Save ngocdaothanh/7315180 to your computer and use it in GitHub Desktop.
Hazelcast Topic 2.5.1 vs 3.1
// https://docs.google.com/file/d/0B4nP_B5KDxyPdnFySDJhVDI2Ujg/edit?usp=sharing
// https://groups.google.com/forum/#!searchin/hazelcast/ngoc/hazelcast/aeSPHp82Dcs/R5ZzkIfvCukJ
package test
import com.hazelcast.core.Hazelcast
object TestManyTopic {
def main(args: Array[String]): Unit = {
val c = null//new Config
val hz = Hazelcast.newHazelcastInstance(c)
val member = hz.getCluster().getLocalMember()
val addr = member.getInetSocketAddress()
val COUNT = 1000000
val array1 = new Array[Long](COUNT)
val array2 = new Array[Long](COUNT)
println("count, create(ms), get(us)")
for (i <- 0 until COUNT) {
val t = hz.getTopic[String]("test-" + i)
t.publish("xxx-" + i)
array1(i) = System.nanoTime()
if (i > 0 && i % 10000 == 0) {
for (j <- i - 10000 until i) {
val t2 = hz.getTopic[String]("test-" + j)
t2.publish("xxx-" + j)
array2(j) = System.nanoTime()
}
printTime(array1, array2, i)
}
}
println("***** END *****")
exit
}
def printTime(array1: Array[Long], array2: Array[Long], start: Int) {
var sum1 = 0.0
var sum2 = 0.0
for (i <- (start - 100 until start)) {
sum1 += array1(i) - array1(i - 1)
sum2 += array2(i) - array2(i - 1)
}
println("%d\t%5.3f\t%5.3f".format(start, (sum1 / 100 / 1000 / 1000), (sum2 / 100 / 1000)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment