Repository: incubator-s2graph Updated Branches: refs/heads/master 245335ad3 -> afbd9e691
remove unused benchmark Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/d6f78154 Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/d6f78154 Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/d6f78154 Branch: refs/heads/master Commit: d6f78154e0d53b18e05e4f4bddb87583a7d21e46 Parents: 245335a Author: daewon <[email protected]> Authored: Thu Mar 29 16:56:47 2018 +0900 Committer: daewon <[email protected]> Committed: Thu Mar 29 16:56:47 2018 +0900 ---------------------------------------------------------------------- .../core/benchmark/JsonBenchmarkSpec.scala | 78 -------------- .../core/benchmark/SamplingBenchmarkSpec.scala | 105 ------------------- 2 files changed, 183 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d6f78154/s2core/src/test/scala/org/apache/s2graph/core/benchmark/JsonBenchmarkSpec.scala ---------------------------------------------------------------------- diff --git a/s2core/src/test/scala/org/apache/s2graph/core/benchmark/JsonBenchmarkSpec.scala b/s2core/src/test/scala/org/apache/s2graph/core/benchmark/JsonBenchmarkSpec.scala deleted file mode 100644 index 05dcd30..0000000 --- a/s2core/src/test/scala/org/apache/s2graph/core/benchmark/JsonBenchmarkSpec.scala +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.s2graph.core.benchmark - -import play.api.libs.json.JsNumber -import play.libs.Json - -class JsonBenchmarkSpec extends BenchmarkCommon { - - "JsonBenchSpec" should { - - "Json Append" >> { - import play.api.libs.json.{Json, _} - val numberJson = Json.toJson((0 to 1000).map { i => s"$i" -> JsNumber(i * i) }.toMap).as[JsObject] - - /** dummy warm-up **/ - (0 to 10000) foreach { n => - Json.obj(s"$n" -> "dummy") ++ numberJson - } - (0 to 10000) foreach { n => - Json.obj(s"$n" -> numberJson) - } - - duration("Append by JsObj ++ JsObj ") { - (0 to 100000) foreach { n => - numberJson ++ Json.obj(s"$n" -> "dummy") - } - } - - duration("Append by Json.obj(newJson -> JsObj)") { - (0 to 100000) foreach { n => - Json.obj(s"$n" -> numberJson) - } - } - true - } - } - - "Make Json" >> { - duration("map to json") { - (0 to 10000) foreach { n => - val numberMaps = (0 to 100).map { n => - n.toString -> JsNumber(n * n) - }.toMap - - Json.toJson(numberMaps) - } - } - - duration("direct") { - (0 to 10000) foreach { n => - var jsObj = play.api.libs.json.Json.obj() - - (0 to 100).foreach { n => - jsObj += (n.toString -> JsNumber(n * n)) - } - } - } - true - } -} http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/d6f78154/s2core/src/test/scala/org/apache/s2graph/core/benchmark/SamplingBenchmarkSpec.scala ---------------------------------------------------------------------- diff --git a/s2core/src/test/scala/org/apache/s2graph/core/benchmark/SamplingBenchmarkSpec.scala b/s2core/src/test/scala/org/apache/s2graph/core/benchmark/SamplingBenchmarkSpec.scala deleted file mode 100644 index ec19641..0000000 --- a/s2core/src/test/scala/org/apache/s2graph/core/benchmark/SamplingBenchmarkSpec.scala +++ /dev/null @@ -1,105 +0,0 @@ -///* -// * Licensed to the Apache Software Foundation (ASF) under one -// * or more contributor license agreements. See the NOTICE file -// * distributed with this work for additional information -// * regarding copyright ownership. The ASF licenses this file -// * to you under the Apache License, Version 2.0 (the -// * "License"); you may not use this file except in compliance -// * with the License. You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, -// * software distributed under the License is distributed on an -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// * KIND, either express or implied. See the License for the -// * specific language governing permissions and limitations -// * under the License. -// */ -// -//package org.apache.s2graph.rest.play.benchmark -// -//import play.api.test.{FakeApplication, PlaySpecification, WithApplication} -// -//import scala.annotation.tailrec -//import scala.util.Random -// -//class SamplingBenchmarkSpec extends BenchmarkCommon with PlaySpecification { -// "sample" should { -// implicit val app = FakeApplication() -// -// "sample benchmark" in new WithApplication(app) { -// @tailrec -// def randomInt(n: Int, range: Int, set: Set[Int] = Set.empty[Int]): Set[Int] = { -// if (set.size == n) set -// else randomInt(n, range, set + Random.nextInt(range)) -// } -// -// // sample using random array -// def randomArraySample[T](num: Int, ls: List[T]): List[T] = { -// val randomNum = randomInt(num, ls.size) -// var sample = List.empty[T] -// var idx = 0 -// ls.foreach { e => -// if (randomNum.contains(idx)) sample = e :: sample -// idx += 1 -// } -// sample -// } -// -// // sample using shuffle -// def shuffleSample[T](num: Int, ls: List[T]): List[T] = { -// Random.shuffle(ls).take(num) -// } -// -// // sample using random number generation -// def rngSample[T](num: Int, ls: List[T]): List[T] = { -// var sampled = List.empty[T] -// val N = ls.size // population -// var t = 0 // total input records dealt with -// var m = 0 // number of items selected so far -// -// while (m < num) { -// val u = Random.nextDouble() -// if ((N - t) * u < num - m) { -// sampled = ls(t) :: sampled -// m += 1 -// } -// t += 1 -// } -// sampled -// } -// -// // test data -// val testLimit = 10000 -// val testNum = 10 -// val testData = (0 to 1000).toList -// -// // dummy for warm-up -// (0 to testLimit) foreach { n => -// randomArraySample(testNum, testData) -// shuffleSample(testNum, testData) -// rngSample(testNum, testData) -// } -// -// duration("Random Array Sampling") { -// (0 to testLimit) foreach { _ => -// val sampled = randomArraySample(testNum, testData) -// } -// } -// -// duration("Shuffle Sampling") { -// (0 to testLimit) foreach { _ => -// val sampled = shuffleSample(testNum, testData) -// } -// } -// -// duration("RNG Sampling") { -// (0 to testLimit) foreach { _ => -// val sampled = rngSample(testNum, testData) -// } -// } -// true -// } -// } -//}
