Skip to content

Instantly share code, notes, and snippets.

@ssk2
Created June 27, 2014 23:41
Show Gist options
  • Save ssk2/b51a786c064ce145b77d to your computer and use it in GitHub Desktop.
Save ssk2/b51a786c064ce145b77d to your computer and use it in GitHub Desktop.
package mesosphere.marathon.tasks
import javax.inject.Inject
import mesosphere.marathon.MarathonConf
import mesosphere.marathon.Protos.MarathonTask
import mesosphere.util.Stats
import org.apache.log4j.Logger
import org.apache.mesos.state.State
class TaskTrackerKeysTest @Inject() (state: State, stats: Stats, config: MarathonConf) {
private[this] val log = Logger.getLogger(getClass.getName)
def createAndWriteTasks(tasks: Int) {
for (id <- Range(1, tasks)) {
val marathonTask = MarathonTask.newBuilder()
.setId(id.toString)
.build
val oldVar = state.fetch("testvar:" + id.toString).get()
// val bytes = new ByteArrayOutputStream()
val newVar = oldVar.mutate(marathonTask.toByteArray)
state.store(newVar)
log.info(s"Wrote state variable for ${id}")
}
}
def expungeTasks(tasks: Int) {
for (id <- Range(1, tasks)) {
val currentVar = state.fetch("testvar:" + id.toString).get()
state.expunge(currentVar)
}
}
def timeRead(tasks: Int) {
state.names()
for (id <- Range(1, tasks)) {
stats.time(s"TaskTrackerKeysTest.read.{$tasks}") {
val currentVar = state.fetch("testvar:" + id.toString).get()
}
}
}
def testTasks(tasks: Int) {
log.info(s"Testing with ${tasks} tasks")
createAndWriteTasks(tasks)
timeRead(tasks)
expungeTasks(tasks)
}
testTasks(1)
testTasks(10)
testTasks(100)
testTasks(1000)
testTasks(10000)
}
@ssk2
Copy link
Author

ssk2 commented Jun 27, 2014

    "TaskTrackerKeysTest.read.{10000}": {
      "count": 9999,
      "max": 0.0031820000000000004,
      "mean": 0.0003676147859922179,
      "min": 0.00025,
      "p50": 0.00035800000000000003,
      "p75": 0.00038700000000000003,
      "p95": 0.0004460999999999999,
      "p98": 0.00047584,
      "p99": 0.00050642,
      "p999": 0.0031077020000000095,
      "stddev": 0.00009803448837355646,
      "m15_rate": 944.6386321714817,
      "m1_rate": 1902.2686031165272,
      "m5_rate": 1721.2438112548307,
      "mean_rate": 199.90736166106683,
      "duration_units": "seconds",
      "rate_units": "calls/second"
    },
    "TaskTrackerKeysTest.read.{1000}": {
      "count": 999,
      "max": 0.003455,
      "mean": 0.00041446446446446447,
      "min": 0.00026700000000000004,
      "p50": 0.000379,
      "p75": 0.000422,
      "p95": 0.000617,
      "p98": 0.00099,
      "p99": 0.0011690000000000001,
      "p999": 0.003455,
      "stddev": 0.00016271512810527827,
      "m15_rate": 9.947456259899235,
      "m1_rate": 163.58240446498064,
      "m5_rate": 109.65256489158647,
      "mean_rate": 5.359367046198372,
      "duration_units": "seconds",
      "rate_units": "calls/second"
    },
    "TaskTrackerKeysTest.read.{100}": {
      "count": 99,
      "max": 0.002258,
      "mean": 0.000460969696969697,
      "min": 0.000275,
      "p50": 0.000386,
      "p75": 0.000467,
      "p95": 0.0009140000000000001,
      "p98": 0.001078,
      "p99": 0.002258,
      "p999": 0.002258,
      "stddev": 0.00023805977874481377,
      "m15_rate": 0.7677293150680969,
      "m1_rate": 15.942926815557785,
      "m5_rate": 10.33650637986812,
      "mean_rate": 0.4890820823494674,
      "duration_units": "seconds",
      "rate_units": "calls/second"
    },
    "TaskTrackerKeysTest.read.{10}": {
      "count": 9,
      "max": 0.008620000000000001,
      "mean": 0.0014042222222222223,
      "min": 0.00041700000000000005,
      "p50": 0.000476,
      "p75": 0.0006500000000000001,
      "p95": 0.008620000000000001,
      "p98": 0.008620000000000001,
      "p99": 0.008620000000000001,
      "p999": 0.008620000000000001,
      "stddev": 0.0027074828151706608,
      "m15_rate": 0.06979357409709978,
      "m1_rate": 1.4493569832325253,
      "m5_rate": 0.9396823981698293,
      "mean_rate": 0.04415603380377924,
      "duration_units": "seconds",
      "rate_units": "calls/second"
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment