Skip to content

Instantly share code, notes, and snippets.

@sam
Forked from mattetti/collection.rb
Created August 7, 2013 16:36
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 sam/6175739 to your computer and use it in GitHub Desktop.
Save sam/6175739 to your computer and use it in GitHub Desktop.
start = Time.now
100.times do
letter_list = []
alphabet = ('a'..'z').to_a
100_000.times{ letter_list << alphabet[rand(26)] }
pick = letter_list.uniq[rand(26)]
before, after = letter_list.partition{|n| n > pick}
end
p (Time.now - start) * 1000
import scala.util.Random
val start = System.currentTimeMillis
(1 to 100).foreach { _ =>
val alphabet = ('a' to 'z').toArray
val letterList = (0 to 100000).map( _ => alphabet(Random.nextInt(26)) )
val pick = letterList.distinct(Random.nextInt(26))
val (before, after) = letterList.partition{ _ > pick }
}
println(System.currentTimeMillis - start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment