Skip to content

Instantly share code, notes, and snippets.

Created December 12, 2012 11:51
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 anonymous/4267208 to your computer and use it in GitHub Desktop.
Save anonymous/4267208 to your computer and use it in GitHub Desktop.
Скрипт для эмуляции модели линейного счетчика
import scala.util._
import scala.collection.immutable._
val r = new Random()
def calculateLoadFactor(m:Int, n:Int) = (1 to n)
.map { _ => BitSet(r.nextInt(m) + 1) }
.foldLeft(BitSet()) { _ | _ }
.size.toFloat / m
(5000 to 100000 by 5000)
.map(i => (i, (1 to 10).map(_ => calculateLoadFactor(10000, i)).sum.toFloat / 10))
.foreach(i => println (i._1 + "\t" + i._2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment