Skip to content
jsuereth edited this page Sep 14, 2010 · 6 revisions

SPerformance is a performance testing framework that aims to allow you to specify performance tests and combine your data into interesting graphs. SPerformance will attempt a “best guess” at how to combine your data in the absence of input.

object MyPerformanceTest extends PerformanceDSLTest with ChartingReporterTest {
  performance of "List" in {
    measure method "foreach" in {
      withSize upTo 1000 withSetup { size =>
        (1 to size).toList
      } run { collection =>
        var tmp = 0
        collection.foreach(x => tmp + x)
      }
    }
  }
  performance of "ListBuffer" in {
    measure method "foreach" in {
      withSize upTo 1000 withSetup { size =>
        val collection = new ListBuffer[Int]
        for( i <- 1 to size) collection += i
        collection
      } run { collection =>
        var tmp = 0
        collection.foreach(x => tmp + x)
      }
    }
  }
  performance of "Array" in {
    measure method "foreach" in {
      withSize upTo 1000 withSetup { size =>
        val collection = new Array[Int](size)
        for(i <- 1 to size) collection(i-1) = i
        collection
      } run { collection =>
        var tmp = 0
        collection.foreach(x => tmp = x * 20)
      }
    }
  }
}

Clone this wiki locally