diff --git a/samples/runner/flag.go b/samples/runner/flag.go index 8a3287a4..abf503c4 100644 --- a/samples/runner/flag.go +++ b/samples/runner/flag.go @@ -46,10 +46,10 @@ var customPortForAkitaRTM = flag.Int("akitartm-port", 0, this number is not given or a invalid number is given number, a random port will be used.`) -var analyszerNameFlag = flag.String("analyzer-name", "", +var analyzerNameFlag = flag.String("analyzer-name", "", "The name of the analyzer to use.") -var analyszerPeriodFlag = flag.Float64("analyzer-period", 0.0, +var analyzerPeriodFlag = flag.Float64("analyzer-period", 0.0000001, "The period to dump the analyzer results.") var visTracing = flag.Bool("trace-vis", false, diff --git a/samples/runner/runner.go b/samples/runner/runner.go index 71f15c72..a9a1e2ce 100644 --- a/samples/runner/runner.go +++ b/samples/runner/runner.go @@ -135,7 +135,7 @@ func (r *Runner) buildTimingPlatform() { b = b.WithMonitor(r.monitor) - b = r.setAnalyszer(b) + b = r.setAnalyzer(b) if *magicMemoryCopy { b = b.WithMagicMemoryCopy() @@ -146,19 +146,20 @@ func (r *Runner) buildTimingPlatform() { r.monitor.StartServer() } -func (*Runner) setAnalyszer( +func (*Runner) setAnalyzer( b R9NanoPlatformBuilder, ) R9NanoPlatformBuilder { - if *analyszerPeriodFlag != 0 && *analyszerNameFlag == "" { - panic("must specify -analyszer-name when using -analyszer-period") + if *analyzerPeriodFlag == 0 && *analyzerNameFlag != "" { + panic("must specify -analyzer-period when using -analyzer-name") } - if *analyszerNameFlag != "" { + if *analyzerPeriodFlag != 0 { b = b.WithPerfAnalyzer( - *analyszerNameFlag, - *analyszerPeriodFlag, + *analyzerNameFlag, + *analyzerPeriodFlag, ) } + return b } diff --git a/samples/runner/timingplatform.go b/samples/runner/timingplatform.go index b2ea6726..01c088fc 100644 --- a/samples/runner/timingplatform.go +++ b/samples/runner/timingplatform.go @@ -241,12 +241,14 @@ func (b *R9NanoPlatformBuilder) setupVisTracing() { } func (b *R9NanoPlatformBuilder) setupPerformanceAnalyzer() { - if b.perfAnalysisFileName != "" { - b.perfAnalyzer = analysis.MakePerfAnalyzerBuilder(). - WithPeriod(sim.VTimeInSec(b.perfAnalyzingPeriod)). - WithDBFilename(b.perfAnalysisFileName). - WithEngine(b.engine). - Build() + b.perfAnalyzer = analysis.MakePerfAnalyzerBuilder(). + WithPeriod(sim.VTimeInSec(b.perfAnalyzingPeriod)). + WithDBFilename(b.perfAnalysisFileName). + WithEngine(b.engine). + Build() + + if b.monitor != nil { + b.monitor.RegisterPerfAnalyzer(b.perfAnalyzer) } }