def main(args: Array[String]) = { test() } def test() { var i = 0 while (i < 10) { testInstanceOf() i += 1 } } def testInstanceOf() { var leftCount = 0 var rightCount = 0 val right = Right("Something", "Something else") val left = Left("LeftS", "LeftSS") var time = System.currentTimeMillis var i = 0L while (i < 500000000L) { if (left.isRight) rightCount += 1 if (right.isRight) rightCount += 1 if (left.isLeft) leftCount += 1 if (right.isLeft) leftCount += 1 i += 1 } time = System.currentTimeMillis - time println(time) println("LeftCount: " + leftCount + ", rightCount: " + rightCount) }