bench

package
v0.0.0-...-cec35f5 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2020 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const IsubataAppHost = "isubata.example.com"

Variables

View Source
var (
	RedirectAttemptedError = fmt.Errorf("redirect attempted")
	RequestTimeoutError    = fmt.Errorf("リクエストがタイムアウトしました")
	UserAgent              = "isucon7q-benchmarker"
	GetTimeout             = 10 * time.Second
	PostTimeout            = 3 * time.Second
	InitializeTimeout      = 10 * time.Second
	SlowThreshold          = 1000 * time.Millisecond
	MaxCheckerRequest      = 6
	DebugMode              = false
)
View Source
var (
	StaticFiles = []*StaticFile{
		&StaticFile{"/css/bootstrap.min.css", 150996, "7e923ad223e9f33e54d22e50cf2bcce5"},
		&StaticFile{"/css/main.css", 1741, "d8c2a974e5816bd9f839f84a77348970"},
		&StaticFile{"/favicon.ico", 318, "7157dc4688c274fe0bc2e3122cac19c9"},
		&StaticFile{"/fonts/glyphicons-halflings-regular.eot", 20127, "f4769f9bdb7466be65088239c12046d1"},
		&StaticFile{"/fonts/glyphicons-halflings-regular.svg", 108738, "89889688147bd7575d6327160d64e760"},
		&StaticFile{"/fonts/glyphicons-halflings-regular.ttf", 45404, "e18bbf611f2a2e43afc071aa2f4e1512"},
		&StaticFile{"/fonts/glyphicons-halflings-regular.woff", 23424, "fa2772327f55d8198301fdb8bcfc8158"},
		&StaticFile{"/fonts/glyphicons-halflings-regular.woff2", 18028, "448c34a56d699c29117adc64c43affeb"},
		&StaticFile{"/js/bootstrap.min.js", 46653, "0827a0bdcd9a917990eee461a77dd33e"},
		&StaticFile{"/js/chat.js", 4162, "c557e68d34fdfb347fa4cf00e1eba7bd"},
		&StaticFile{"/js/jquery.min.js", 86659, "c9f5aeeca3ad37bf2aa006139b935f0a"},
		&StaticFile{"/js/tether.min.js", 24632, "1c4a5999a2b43cdd3aaa88a04f24c961"},
	}
)

Functions

func CheckFecthRegisterAndLogin

func CheckFecthRegisterAndLogin(ctx context.Context, state *State) error

fetch 検証用のユーザ作成

func CheckFecthUnreadCount

func CheckFecthUnreadCount(ctx context.Context, state *State) error

func CheckGetAddChannel

func CheckGetAddChannel(ctx context.Context, state *State) error

func CheckGetChannel

func CheckGetChannel(ctx context.Context, state *State) error

func CheckGetHistory

func CheckGetHistory(ctx context.Context, state *State, chanID int, mode PageFollowMode) error

func CheckGetProfileFail

func CheckGetProfileFail(ctx context.Context, state *State) error

func CheckLogin

func CheckLogin(ctx context.Context, state *State) error

func CheckMessageScenario

func CheckMessageScenario(ctx context.Context, state *State) error

func CheckNotLoggedInUser

func CheckNotLoggedInUser(ctx context.Context, state *State) error

func CheckPostAddChannel

func CheckPostAddChannel(ctx context.Context, state *State) (int, error)

func CheckPostAddChannelFail

func CheckPostAddChannelFail(ctx context.Context, state *State) error

func CheckRegisterProfile

func CheckRegisterProfile(ctx context.Context, state *State) error

func CheckStaticFiles

func CheckStaticFiles(ctx context.Context, state *State) error

func GenerateInitialDataSetSQL

func GenerateInitialDataSetSQL(outputPath string)

func GetBuffer

func GetBuffer() *bytes.Buffer

func GetCheckerErrors

func GetCheckerErrors() []error

func GetLastCheckerError

func GetLastCheckerError() (err error, t time.Time)

func GetLastSlowPath

func GetLastSlowPath() (path string, t time.Time)

func GetRandomTargetHost

func GetRandomTargetHost() string

func GetTargetHosts

func GetTargetHosts() []string

func GuardCheckerError

func GuardCheckerError(guard bool)

func LoadGetChannel

func LoadGetChannel(ctx context.Context, state *State) error

func LoadGetHistory

func LoadGetHistory(ctx context.Context, state *State) error

func LoadProfile

func LoadProfile(ctx context.Context, state *State) error

func LoadReadOnlyUser

func LoadReadOnlyUser(ctx context.Context, state *State, chanID int) error

func LoadReadWriteUser

func LoadReadWriteUser(ctx context.Context, state *State, chanID int) error

func LoadRegister

func LoadRegister(ctx context.Context, state *State) error

func PrepareDataSet

func PrepareDataSet()

func PutBuffer

func PutBuffer(buf *bytes.Buffer)

func RandomAlphabetString

func RandomAlphabetString(n int) string

func RandomText

func RandomText() string

func SetTargetHosts

func SetTargetHosts(target []string)

Types

type AppUser

type AppUser struct {
	sync.Mutex
	Name        string
	Password    string
	DisplayName string
	Avatar      *Avatar
}

type Avatar

type Avatar struct {
	FilePath string
	Ext      string
	SHA1     string
	MD5      string
	Bytes    []byte
}

type BenchDataSet

type BenchDataSet struct {
	Users    []*AppUser
	NewUsers []*AppUser

	Channels    []*Channel
	NewChannels []*Channel

	Avatars       []*Avatar
	LargeAvatars  []*Avatar
	DefaultAvatar *Avatar

	Texts    []string
	Messages []*MessageInfo
}
var (
	DataPath = "./data"
	DataSet  BenchDataSet
)

type Channel

type Channel struct {
	ID          int
	Name        string
	Description string
}

type CheckAction

type CheckAction struct {
	Method string
	Path   string

	ContentType string
	PostBody    io.Reader         // for "multipart/form-data"
	PostData    map[string]string // for "application/x-www-form-urlencoded"
	Headers     map[string]string

	ExpectedStatusCode int
	ExpectedLocation   *regexp.Regexp
	ExpectedHeaders    map[string]string
	Description        string
	CheckFunc          func(*http.Response, *bytes.Buffer) error

	EnableCache          bool
	SkipIfCacheAvailable bool
	DisableSlowChecking  bool
}

type Checker

type Checker struct {
	Client *http.Client
	Cache  *urlcache.CacheStore
	// contains filtered or unexported fields
}

func NewChecker

func NewChecker() *Checker

func (*Checker) NewRequest

func (c *Checker) NewRequest(method, uri string, body io.Reader) (*http.Request, error)

func (*Checker) OnError

func (c *Checker) OnError(a *CheckAction, req *http.Request, err error) error

func (*Checker) Play

func (c *Checker) Play(ctx context.Context, a *CheckAction) error

func (*Checker) ResetCookie

func (c *Checker) ResetCookie()

type CheckerError

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

func (*CheckerError) Error

func (e *CheckerError) Error() string

func (*CheckerError) IsFatal

func (e *CheckerError) IsFatal() bool

func (*CheckerError) IsTimeout

func (e *CheckerError) IsTimeout() bool

type CheckerTransport

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

func (*CheckerTransport) RoundTrip

func (ct *CheckerTransport) RoundTrip(req *http.Request) (*http.Response, error)

type JsonMessage

type JsonMessage struct {
	ID      int      `json:"id"`
	Content string   `json:"content"`
	Date    string   `json:"date"`
	User    JsonUser `json:"user"`
}

type JsonUnreadInfo

type JsonUnreadInfo struct {
	ChannelID int `json:"channel_id"`
	Unread    int `json:"unread"`
}

type JsonUser

type JsonUser struct {
	ID          int    `json:"id"`
	AvatarIcon  string `json:"avatar_icon"`
	DisplayName string `json:"display_name"`
	Name        string `json:"name"`
}

type MessageInfo

type MessageInfo struct {
	UserName      string
	ChannelID     int
	Message       string
	SendBeginTime time.Time
	SendEndTime   time.Time
	SendComplete  bool
}

type PageFollowMode

type PageFollowMode int
const (
	FollowModeRandom PageFollowMode = iota
	FollowModeHead
	FollowModeTail
)

type State

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

func (*State) AddChannel

func (s *State) AddChannel(id int, c *Channel)

func (*State) AddSendMessage

func (s *State) AddSendMessage(x *MessageInfo) (func(), bool)

func (*State) DistributeTmpChannelIDs

func (s *State) DistributeTmpChannelIDs()

func (*State) FindUserByName

func (s *State) FindUserByName(name string) (*AppUser, bool)

func (*State) GetActiveChannelID

func (s *State) GetActiveChannelID() int

func (*State) GetChannel

func (s *State) GetChannel(chanID int) (*Channel, bool)

func (*State) GetChecker

func (s *State) GetChecker(u *AppUser) *Checker

func (*State) GetInactiveChannelID

func (s *State) GetInactiveChannelID() int

func (*State) GetMsgCheckChannelID

func (s *State) GetMsgCheckChannelID() int

func (*State) GetRandomChannelID

func (s *State) GetRandomChannelID() int

func (*State) Init

func (s *State) Init()

func (*State) PopNewUser

func (s *State) PopNewUser() (*AppUser, *Checker, func())

func (*State) PopRandomUser

func (s *State) PopRandomUser() (*AppUser, *Checker, func())

func (*State) PushUser

func (s *State) PushUser(u *AppUser)

func (*State) SnapshotMessageCount

func (s *State) SnapshotMessageCount() (map[int]int, map[int]int)

func (*State) TotalChannelCount

func (s *State) TotalChannelCount() int

func (*State) ValidateHistoryMessage

func (s *State) ValidateHistoryMessage(chanID int, userName string, msg string, date string) error

func (*State) ValidateJsonMessage

func (s *State) ValidateJsonMessage(chanID int, msg *JsonMessage) error

type StaticFile

type StaticFile struct {
	Path string
	Size int64
	Hash string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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