Weitere ähnliche Inhalte
Ähnlich wie GPerf Using Jesque (20)
Kürzlich hochgeladen (20)
GPerf Using Jesque
- 5. Creating Jobs
perf {
runners {
largeNumberPerformanceRunner {
description = 'Large Number Performance Test'
maxWorkers = 20
workerClass = com.perf.runners.math.LargeNumberPerformanceService
}
}
}
class LargeNumberPerformanceService extends AbstractPerformanceService {
Result performTest() {
Long result = 1
def executionTime = benchmark {
100000.times {
result += it
}
}
new SimpleResult(testName: 'Long Number Performance Service', executionTime: executionTime)
}
}
- 6. The Jesque Job
class PerformanceRunnerJob {
GrailsApplication grailsApplication
RedisService redisService
ResultsService resultsService
def executorService
def perform(jobName, workers) {
println "jesque queueing up job ${jobName} with ${workers} threads"
Class clazz = grailsApplication.config?.perf?.runners[jobName]?.workerClass
if(!clazz) {
log.error "Can not start a performance worker without a workerClass defined in the config attribute"
}
PerformanceService service = (PerformanceService) grailsApplication.mainContext.getBean(clazz)
Integer.parseInt(workers).times {
runAsync {
println "running ${jobName} on thread :: ${Thread.currentThread().id}"
while(redisService.get(jobName) == PerformanceConstants.RUNNING) {
saveResults(jobName, service.performTest())
}
}
}
}
private void saveResults(String jobName, Result result) {
log.debug result
resultsService.saveResults(jobName, result)
}
}
Hinweis der Redaktion
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n