Fix usages of ArgType.Choice in benchmarks (#4562)
This commit is contained in:
committed by
Stanislav Erokhin
parent
211c160558
commit
e940a1d6bb
@@ -156,11 +156,17 @@ class VideoPlayer(val requestedSize: Dimensions?) : DisposableContainer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class Mode {
|
||||||
|
VIDEO,
|
||||||
|
AUDIO,
|
||||||
|
BOTH
|
||||||
|
}
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
val argParser = ArgParser("videoplayer")
|
val argParser = ArgParser("videoplayer")
|
||||||
val mode by argParser.option(
|
val mode by argParser.option(
|
||||||
ArgType.Choice(listOf("video", "audio", "both")), shortName = "m", description = "Play mode")
|
ArgType.Choice<Mode>(), shortName = "m", description = "Play mode")
|
||||||
.default("both")
|
.default(BOTH)
|
||||||
val size by argParser.option(ArgType.Int, shortName = "s", description = "Required size of videoplayer window")
|
val size by argParser.option(ArgType.Int, shortName = "s", description = "Required size of videoplayer window")
|
||||||
.delimiter(",")
|
.delimiter(",")
|
||||||
val fileName by argParser.argument(ArgType.String, description = "File to play")
|
val fileName by argParser.argument(ArgType.String, description = "File to play")
|
||||||
|
|||||||
@@ -150,8 +150,8 @@ fun main(args: Array<String>) {
|
|||||||
"Meaningful performance changes").default(1.0)
|
"Meaningful performance changes").default(1.0)
|
||||||
val useShortForm by argParser.option(ArgType.Boolean, "short", "s",
|
val useShortForm by argParser.option(ArgType.Boolean, "short", "s",
|
||||||
"Show short version of report").default(false)
|
"Show short version of report").default(false)
|
||||||
val renders by argParser.option(ArgType.Choice(listOf("text", "html", "teamcity", "statistics", "metrics")),
|
val renders by argParser.option(ArgType.Choice<RenderType>(), shortName = "r",
|
||||||
shortName = "r", description = "Renders for showing information").multiple().default(listOf("text"))
|
description = "Renders for showing information").multiple().default(listOf(RenderType.TEXT))
|
||||||
val user by argParser.option(ArgType.String, shortName = "u", description = "User access information for authorization")
|
val user by argParser.option(ArgType.String, shortName = "u", description = "User access information for authorization")
|
||||||
|
|
||||||
argParser.parse(args)
|
argParser.parse(args)
|
||||||
@@ -169,7 +169,7 @@ fun main(args: Array<String>) {
|
|||||||
|
|
||||||
var outputFile = output
|
var outputFile = output
|
||||||
renders.forEach {
|
renders.forEach {
|
||||||
Render.getRenderByName(it).print(summaryReport, useShortForm, outputFile)
|
it.render.print(summaryReport, useShortForm, outputFile)
|
||||||
outputFile = null
|
outputFile = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+7
-12
@@ -10,21 +10,16 @@ import org.jetbrains.report.*
|
|||||||
|
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
|
||||||
|
enum class RenderType(val render: Render) {
|
||||||
|
TEXT(TextRender()),
|
||||||
|
HTML(HTMLRender()),
|
||||||
|
TEAMCITY(TeamCityStatisticsRender()),
|
||||||
|
STATISTICS(StatisticsRender())
|
||||||
|
}
|
||||||
|
|
||||||
// Base class for printing report in different formats.
|
// Base class for printing report in different formats.
|
||||||
abstract class Render {
|
abstract class Render {
|
||||||
|
|
||||||
companion object {
|
|
||||||
fun getRenderByName(name: String) =
|
|
||||||
when (name) {
|
|
||||||
"text" -> TextRender()
|
|
||||||
"html" -> HTMLRender()
|
|
||||||
"teamcity" -> TeamCityStatisticsRender()
|
|
||||||
"statistics" -> StatisticsRender()
|
|
||||||
"metrics" -> MetricResultsRender()
|
|
||||||
else -> error("Unknown render $name")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract val name: String
|
abstract val name: String
|
||||||
|
|
||||||
abstract fun render(report: SummaryBenchmarksReport, onlyChanges: Boolean = false): String
|
abstract fun render(report: SummaryBenchmarksReport, onlyChanges: Boolean = false): String
|
||||||
|
|||||||
Reference in New Issue
Block a user