Skip to content

Commit

Permalink
Speedup drop_stage
Browse files Browse the repository at this point in the history
  • Loading branch information
ponkotuy committed Feb 12, 2015
1 parent df12928 commit 6fb0a9e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
11 changes: 11 additions & 0 deletions profiler/src/main/scala/Common.scala
@@ -0,0 +1,11 @@
import play.api.libs.iteratee.Iteratee
import play.api.libs.concurrent.Execution.Implicits._

/**
*
* @author ponkotuy
* Date: 15/02/13.
*/
object Common {
val printIteratee: Iteratee[Array[Byte], Unit] = Iteratee.foreach(ary => println(ary.length))
}
25 changes: 25 additions & 0 deletions profiler/src/main/scala/DropStage.scala
@@ -0,0 +1,25 @@
import controllers.ViewSta
import play.api.test.Helpers._
import play.api.test._

import scala.concurrent.Await
import scala.util.Try
import scala.concurrent.duration._

/**
*
* @author ponkotuy
* Date: 15/02/13.
*/
object DropStage extends App {
import Common._
val count = Try { args(0).toInt }.getOrElse(100)
running(FakeApplication(additionalConfiguration = Settings.dbMap)) {
val futures = (1 to count).map { _ =>
ViewSta.dropStage().apply(FakeRequest())
}
futures.map { f =>
Await.result(f, 10.second).body.run(printIteratee)
}
}
}
4 changes: 1 addition & 3 deletions profiler/src/main/scala/UserShipPlay.scala
@@ -1,11 +1,9 @@
import controllers.UserView
import play.api.libs.iteratee.Iteratee
import play.api.test.Helpers._
import play.api.test._

import scala.concurrent.Await
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.Try

/**
Expand All @@ -14,9 +12,9 @@ import scala.util.Try
* Date: 15/02/10.
*/
object UserShipPlay extends App {
import Common._
val count = Try { args(0).toInt }.getOrElse(100)
val itr = new UserIterator(0)
val printIteratee: Iteratee[Array[Byte], Unit] = Iteratee.foreach(ary => println(ary.length))
running(FakeApplication(additionalConfiguration = Settings.dbMap)) {
val futures = itr.take(count).toList.map { user =>
UserView.ship(user).apply(FakeRequest())
Expand Down
2 changes: 1 addition & 1 deletion server/app/models/db/BattleResult.scala
Expand Up @@ -159,7 +159,7 @@ object BattleResult extends SQLSyntaxSupport[BattleResult] {

def countAllByStage()(implicit session: DBSession = autoSession): List[(Stage, Long)] = {
withSQL {
select(br.*, sqls"count(1) as cnt")
select(br.areaId, br.infoNo, sqls"count(1) as cnt")
.from(BattleResult as br)
.groupBy(br.areaId, br.infoNo)
.orderBy(br.areaId, br.infoNo)
Expand Down

0 comments on commit 6fb0a9e

Please sign in to comment.