How to use RunScenario method of performance_test Package

Best Ginkgo code snippet using performance_test.RunScenario

performance_suite_test.go

Source:performance_suite_test.go Github

copy

Full Screen

...204 GoModDownload("performance")205 }206 for idx, run := range runs {207 fmt.Printf("%d - %s\n", idx, run.Name())208 RunScenario(experiments[run.Name()].NewStopwatch(), run, gmeasure.Annotation(fmt.Sprintf("%d", idx+1)))209 }210 for name, experiment := range experiments {211 cache.Save(name, cacheVersion, experiment)212 }213}214func AnalyzeCache(cache gmeasure.ExperimentCache) {215 headers, err := cache.List()216 Ω(err).ShouldNot(HaveOccurred())217 experiments := []*gmeasure.Experiment{}218 for _, header := range headers {219 experiments = append(experiments, cache.Load(header.Name, header.Version))220 }221 for _, measurement := range []string{"first-output", "total-runtime"} {222 stats := []gmeasure.Stats{}223 for _, experiment := range experiments {224 stats = append(stats, experiment.GetStats(measurement))225 }226 AddReportEntry(measurement, gmeasure.RankStats(gmeasure.LowerMedianIsBetter, stats...))227 }228}229func RunScenario(stopwatch *gmeasure.Stopwatch, settings ScenarioSettings, annotation gmeasure.Annotation) {230 if settings.ClearGoModCache {231 gmcm.Clear()232 }233 if settings.GoModDownloadFirst {234 GoModDownload(settings.Fixture)235 stopwatch.Record("mod-download", annotation)236 }237 if settings.UseGoTestDirectly {238 RunScenarioWithGoTest(stopwatch, settings, annotation)239 } else {240 RunScenarioWithGinkgoInternals(stopwatch, settings, annotation)241 }242}243/* CompileAndRun uses the Ginkgo CLIs internals to compile and run tests with different possible settings governing concurrency and ordering */244func RunScenarioWithGinkgoInternals(stopwatch *gmeasure.Stopwatch, settings ScenarioSettings, annotation gmeasure.Annotation) {245 cliConfig := types.NewDefaultCLIConfig()246 cliConfig.Recurse = settings.Recurse247 suiteConfig := types.NewDefaultSuiteConfig()248 reporterConfig := types.NewDefaultReporterConfig()249 reporterConfig.Succinct = true250 goFlagsConfig := types.NewDefaultGoFlagsConfig()251 suites := internal.FindSuites([]string{pfm.PathTo(settings.Fixture)}, cliConfig, true)252 Ω(suites).Should(HaveLen(settings.NumSuites))253 compile := make(chan internal.TestSuite, len(suites))254 compiled := make(chan internal.TestSuite, len(suites))255 completed := make(chan internal.TestSuite, len(suites))256 firstOutputOnce := sync.Once{}257 for compiler := 0; compiler < settings.ConcurrentCompilers; compiler++ {258 go func() {259 for suite := range compile {260 if !suite.State.Is(internal.TestSuiteStateCompiled) {261 subStopwatch := stopwatch.NewStopwatch()262 suite = internal.CompileSuite(suite, goFlagsConfig)263 subStopwatch.Record("compile-test: "+suite.PackageName, annotation)264 Ω(suite.CompilationError).Should(BeNil())265 }266 compiled <- suite267 }268 }()269 }270 if settings.CompileFirstSuiteSerially {271 compile <- suites[0]272 suites[0] = <-compiled273 }274 for runner := 0; runner < settings.ConcurrentRunners; runner++ {275 go func() {276 for suite := range compiled {277 firstOutputOnce.Do(func() {278 stopwatch.Record("first-output", annotation, gmeasure.Style("{{cyan}}"))279 })280 subStopwatch := stopwatch.NewStopwatch()281 suite = internal.RunCompiledSuite(suite, suiteConfig, reporterConfig, cliConfig, goFlagsConfig, []string{})282 subStopwatch.Record("run-test: "+suite.PackageName, annotation)283 Ω(suite.State).Should(Equal(internal.TestSuiteStatePassed))284 completed <- suite285 }286 }()287 }288 for _, suite := range suites {289 compile <- suite290 }291 completedSuites := []internal.TestSuite{}292 for suite := range completed {293 completedSuites = append(completedSuites, suite)294 if len(completedSuites) == len(suites) {295 close(completed)296 close(compile)297 close(compiled)298 }299 }300 stopwatch.Record("total-runtime", annotation, gmeasure.Style("{{green}}"))301 internal.Cleanup(goFlagsConfig, completedSuites...)302}303func RunScenarioWithGoTest(stopwatch *gmeasure.Stopwatch, settings ScenarioSettings, annotation gmeasure.Annotation) {304 defer func() {305 stopwatch.Record("total-runtime", annotation, gmeasure.Style("{{green}}"))306 }()307 if settings.GoTestRecurse {308 cmd := exec.Command("go", "test", "-count=1", "./...")309 cmd.Dir = pfm.PathTo(settings.Fixture)310 sess, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)311 Ω(err).ShouldNot(HaveOccurred())312 Eventually(sess).Should(gbytes.Say(`.`)) //should say _something_ eventually!313 stopwatch.Record("first-output", annotation, gmeasure.Style("{{cyan}}"))314 Eventually(sess).Should(gexec.Exit(0))315 return316 }317 cliConfig := types.NewDefaultCLIConfig()...

Full Screen

Full Screen

RunScenario

Using AI Code Generation

copy

Full Screen

1import (2type SimpleStruct struct {3}4func main() {5 pmem.Init("/mnt/mem/pmemfile")6 pmemobj := pmem.NewPmemObj("/mnt/mem/pmemfile", 1024*1024*1024)7 defer pmemobj.Close()8 tx := transaction.NewTx(pmemobj)9 defer tx.End()

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful