loadtest

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: AGPL-3.0 Imports: 38 Imported by: 0

Documentation

Overview

Copyright © 2022 Polygon <engineering@polygon.technology>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

View Source
var LoadtestCmd = &cobra.Command{
	Use:   "loadtest rpc-endpoint",
	Short: "A simple script for quickly running a load test",
	Long:  `Loadtest gives us a simple way to run a generic load test against an eth/EVM style json RPC endpoint`,
	RunE: func(cmd *cobra.Command, args []string) error {
		log.Debug().Msg("Starting Loadtest")

		err := runLoadTest(cmd.Context())
		if err != nil {
			return err
		}
		return nil
	},
	Args: func(cmd *cobra.Command, args []string) error {
		setLogLevel(inputLoadTestParams)
		if len(args) != 1 {
			return fmt.Errorf("expected exactly one argument")
		}
		url, err := url.Parse(args[0])
		if err != nil {
			log.Error().Err(err).Msg("Unable to parse url input error")
			return err
		}
		if url.Scheme != "http" && url.Scheme != "https" && url.Scheme != "ws" && url.Scheme != "wss" {
			return fmt.Errorf("the scheme %s is not supported", url.Scheme)
		}
		inputLoadTestParams.URL = url
		r := regexp.MustCompile(fmt.Sprintf("^[%s]+$", strings.Join(validLoadTestModes, "")))
		if !r.MatchString(*inputLoadTestParams.Mode) {
			return fmt.Errorf("the mode %s is not recognized", *inputLoadTestParams.Mode)
		}
		return nil
	},
}

LoadtestCmd represents the loadtest command

Functions

This section is empty.

Types

type Latency

type Latency struct {
	Min    float64
	Median float64
	Max    float64
}

type Summary

type Summary struct {
	BlockNumber uint64
	Time        time.Time
	GasLimit    uint64
	GasUsed     uint64
	NumTx       int
	Utilization float64
	Latencies   Latency
}

type SummaryOutput

type SummaryOutput struct {
	Summaries          []Summary
	SuccessfulTx       int64
	TotalTx            int64
	TotalMiningTime    time.Duration
	TotalGasUsed       uint64
	TransactionsPerSec float64
	GasPerSecond       float64
	Latencies          Latency
}

Jump to

Keyboard shortcuts

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