status

package
v0.0.0-...-09ecf48 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2017 License: Apache-2.0 Imports: 17 Imported by: 0

README

bench golang

on Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz, 16GB ram

$ ./status/run-test.sh                                                                              

====================

Cockroachdb

islatest
--------
BenchmarkCreate-4                    	     500	  10468330 ns/op
BenchmarkUpdateStatus-4              	     500	   9011778 ns/op
BenchmarkSelectEntityoneByStatus-4   	     300	  18448235 ns/op
BenchmarkSelectEntityoneOneByPK-4    	     300	  17290208 ns/op
PASS
ok  	github.com/vincentserpoul/playwithsql/status	26.662s

lateststatus
------------
BenchmarkCreate-4                    	     300	  13330483 ns/op
BenchmarkUpdateStatus-4              	     500	  10548141 ns/op
BenchmarkSelectEntityoneByStatus-4   	     300	  15148713 ns/op
BenchmarkSelectEntityoneOneByPK-4    	     500	   9512001 ns/op
PASS
ok  	github.com/vincentserpoul/playwithsql/status	24.508s

history
-------
BenchmarkCreate-4                    	     500	  10360480 ns/op
BenchmarkUpdateStatus-4              	     500	  10700921 ns/op
BenchmarkSelectEntityoneByStatus-4   	    3000	   1349362 ns/op
BenchmarkSelectEntityoneOneByPK-4    	    5000	   1199731 ns/op
PASS
ok  	github.com/vincentserpoul/playwithsql/status	23.754s

====================

MSSQL

islatest
--------
BenchmarkCreate-4                    	    2000	   2151683 ns/op
BenchmarkUpdateStatus-4              	    3000	   1502009 ns/op
BenchmarkSelectEntityoneByStatus-4   	   10000	    410183 ns/op
BenchmarkSelectEntityoneOneByPK-4    	   10000	    371751 ns/op
PASS
ok  	github.com/vincentserpoul/playwithsql/status	17.162s

lateststatus
------------
BenchmarkCreate-4                    	    2000	   2441415 ns/op
BenchmarkUpdateStatus-4              	    2000	   1934141 ns/op
BenchmarkSelectEntityoneByStatus-4   	   10000	    409696 ns/op
BenchmarkSelectEntityoneOneByPK-4    	   10000	    358960 ns/op
PASS
ok  	github.com/vincentserpoul/playwithsql/status	17.056s

history
-------
BenchmarkCreate-4                    	    2000	   1877509 ns/op
BenchmarkUpdateStatus-4              	    3000	   1361104 ns/op
BenchmarkSelectEntityoneByStatus-4   	   10000	    358764 ns/op
BenchmarkSelectEntityoneOneByPK-4    	   10000	    324062 ns/op
PASS
ok  	github.com/vincentserpoul/playwithsql/status	15.149s

====================

MySQL 

islatest
--------
BenchmarkCreate-4                    	    2000	   2499545 ns/op
BenchmarkUpdateStatus-4              	    2000	   2526334 ns/op
BenchmarkSelectEntityoneByStatus-4   	   10000	    426611 ns/op
BenchmarkSelectEntityoneOneByPK-4    	   10000	    418569 ns/op
PASS
ok  	github.com/vincentserpoul/playwithsql/status	19.206s

lateststatus
------------
BenchmarkCreate-4                    	    2000	   2069397 ns/op
BenchmarkUpdateStatus-4              	    2000	   2056994 ns/op
BenchmarkSelectEntityoneByStatus-4   	   10000	    422564 ns/op
BenchmarkSelectEntityoneOneByPK-4    	   10000	    368221 ns/op
PASS
ok  	github.com/vincentserpoul/playwithsql/status	16.790s

history
-------
BenchmarkCreate-4                    	    2000	   1740044 ns/op
BenchmarkUpdateStatus-4              	    2000	   2054322 ns/op
BenchmarkSelectEntityoneByStatus-4   	   10000	    368390 ns/op
BenchmarkSelectEntityoneOneByPK-4    	   10000	    319086 ns/op
PASS
ok  	github.com/vincentserpoul/playwithsql/status	15.055s

====================

Postgres

islatest
--------
BenchmarkCreate-4                    	    2000	   2063406 ns/op
BenchmarkUpdateStatus-4              	    2000	   1775458 ns/op
BenchmarkSelectEntityoneByStatus-4   	   10000	    634958 ns/op
BenchmarkSelectEntityoneOneByPK-4    	   10000	    491673 ns/op
PASS
ok  	github.com/vincentserpoul/playwithsql/status	19.600s

lateststatus
------------
BenchmarkCreate-4                    	    3000	   1724629 ns/op
BenchmarkUpdateStatus-4              	    2000	   1644451 ns/op
BenchmarkSelectEntityoneByStatus-4   	    5000	    754812 ns/op
BenchmarkSelectEntityoneOneByPK-4    	   10000	    494935 ns/op
PASS
ok  	github.com/vincentserpoul/playwithsql/status	17.760s

history
-------
BenchmarkCreate-4                    	    3000	   1751059 ns/op
BenchmarkUpdateStatus-4              	    2000	   2095055 ns/op
BenchmarkSelectEntityoneByStatus-4   	    5000	    639743 ns/op
BenchmarkSelectEntityoneOneByPK-4    	   10000	    313535 ns/op
PASS
ok  	github.com/vincentserpoul/playwithsql/status	16.323s

====================

SQLite

islatest
--------
BenchmarkCreate-4                    	    1000	   5139560 ns/op
BenchmarkUpdateStatus-4              	    1000	   5128113 ns/op
BenchmarkSelectEntityoneByStatus-4   	   50000	     93758 ns/op
BenchmarkSelectEntityoneOneByPK-4    	  100000	     90393 ns/op
PASS
ok  	github.com/vincentserpoul/playwithsql/status	26.589s

lateststatus
------------
BenchmarkCreate-4                    	    1000	   6139074 ns/op
BenchmarkUpdateStatus-4              	    1000	   5803292 ns/op
BenchmarkSelectEntityoneByStatus-4   	   50000	    124262 ns/op
BenchmarkSelectEntityoneOneByPK-4    	   50000	    114864 ns/op
PASS
ok  	github.com/vincentserpoul/playwithsql/status	27.136s

history
-------
BenchmarkCreate-4                    	    1000	   5519332 ns/op
BenchmarkUpdateStatus-4              	    1000	   5600910 ns/op
BenchmarkSelectEntityoneByStatus-4   	   50000	     91100 ns/op
BenchmarkSelectEntityoneOneByPK-4    	  100000	     77634 ns/op
PASS
ok  	github.com/vincentserpoul/playwithsql/status	26.121s


Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionID

type ActionID int

ActionID represents the action performed on the tradeoffer request

const (
	// ActionCreate is triggered when the Entityone is created
	ActionCreate ActionID = 1
	// ActionCancel  is triggered when the Entityone is cancelled
	ActionCancel ActionID = 999
	// ActionClose is triggered when the Entityone is closed
	ActionClose ActionID = 500
)

func (ActionID) String

func (s ActionID) String() string

type Entityone

type Entityone struct {
	ID          int64     `db:"entityone_id" json:"entityone_id"`
	TimeCreated time.Time `db:"time_created" json:"time_created"`
	Status      `json:"status"`
}

Entityone represents an event

func SelectEntityoneByStatus

func SelectEntityoneByStatus(
	ctx context.Context,
	q *sqlx.DB,
	link SQLLink,
	statusID StatusID,
) (selectedEntity []*Entityone, err error)

SelectEntityoneByStatus will retrieve one entityone from a selected status

func SelectEntityoneOneByPK

func SelectEntityoneOneByPK(
	ctx context.Context,
	q *sqlx.DB,
	link SQLLink,
	entityID int64,
) (selectedEntity *Entityone, err error)

SelectEntityoneOneByPK will retrieve one entityone from a selected status

func (*Entityone) Create

func (e *Entityone) Create(ctx context.Context, db *sqlx.DB, link SQLLink) (err error)

Create will create an entityone

func (*Entityone) UpdateStatus

func (e *Entityone) UpdateStatus(
	ctx context.Context,
	db *sqlx.DB,
	link SQLLink,
	actionID ActionID,
	statusID StatusID,
) (err error)

UpdateStatus will update the status of an Entityone into db

type SQLIntImpl

type SQLIntImpl struct {
	SQLLink
}

SQLIntImpl allows to contains an interface

func GetSQLIntImpl

func GetSQLIntImpl(dbType string, schemaType string) *SQLIntImpl

GetSQLIntImpl returns the type of link according to the dbtype

type SQLLink interface {
	MigrateUp(ctx context.Context, exec sqlx.ExecerContext) (errExec error)
	MigrateDown(ctx context.Context, exec sqlx.ExecerContext) (errExec error)
	Create(ctx context.Context, exec *sqlx.Tx, actionID, statusID int) (int64, error)
	SaveStatus(
		ctx context.Context,
		exec *sqlx.Tx,
		entityID int64,
		actionID int,
		statusID int,
	) error
	SelectEntityone(
		ctx context.Context,
		q *sqlx.DB,
		entityIDs []int64,
		isStatusIDs []int,
		notStatusIDs []int,
		neverStatusIDs []int,
		hasStatusIDs []int,
		limit int,
	) (*sqlx.Rows, error)
}

SQLLink is used to define SQL interactions

type Status

type Status struct {
	ActionID    ActionID  `db:"action_id" json:"action_id"`
	StatusID    StatusID  `db:"status_id" json:"status_id"`
	TimeCreated time.Time `db:"status_time_created" json:"time_created"`
}

Status of the entity

type StatusID

type StatusID int

StatusID represents the state of the tradeoffer, see constants

const (
	// StatusCreated is when a Entityone is just created
	StatusCreated StatusID = 1
	// StatusCancelled when a Entityone is cancelled
	StatusCancelled StatusID = 999
	// StatusClosed is not changeable anymore, final status
	StatusClosed StatusID = 1000
)

func (StatusID) String

func (s StatusID) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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