benchmark

package
v0.1.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2025 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CMD = &cobra.Command{
	Use:   "benchmark",
	Short: "Run benchmarks of ssv node",
	Run: func(cobraCMD *cobra.Command, args []string) {
		var (
			ctx    context.Context
			cancel context.CancelFunc
		)
		if configs.Values.Benchmark.Duration == 0 {
			ctx, cancel = context.WithCancel(context.Background())
		} else {
			ctx, cancel = context.WithTimeout(context.Background(), configs.Values.Benchmark.Duration)
		}

		isValid, err := configs.Values.Benchmark.Validate()
		if !isValid {
			panic(err.Error())
		}

		metrics, err := LoadEnabledMetrics(configs.Values)
		if err != nil {
			panic(err.Error())
		}

		benchmarkService := New(metrics, report.New())

		go benchmarkService.Start(ctx)

		slog.With("port", configs.Values.Benchmark.Server.Port).Info("running web host")
		host := host.New(configs.Values.Benchmark.Server.Port,
			route.
				NewRouter().
				WithMetrics().
				Router())
		host.Run()

		lifecycle.ListenForApplicationShutDown(ctx, func() {
			cancel()
			slog.Warn("terminating the application")
		}, make(chan os.Signal))
	},
}

Functions

func LoadEnabledMetrics

func LoadEnabledMetrics(config configs.Config) (map[metric.Group][]metricService, error)

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(
	metrics map[metric.Group][]metricService,
	reportService reportService,
) *Service

func (*Service) Start

func (s *Service) Start(ctx context.Context)

Directories

Path Synopsis
metrics
ssv

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL