goqueuestest

package
v0.0.0-...-a8a18e3 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Unlicense Imports: 5 Imported by: 0

README

Go Queues Test

Performance test of different concurrent queue implementations

--

Warning: not for production use!

--

Available Structure:

  • CFifo : Channel based fifo
  • LcLifo : list.List based lifo using chan for locking
  • LcFifo : list.List based fifo using chan for locking
  • LmLifo : list.List based lifo using mutex for locking
  • LmFifo : list.List based fifo using mutex for locking
  • ZLifo : lockfree lifo implementation (broken, ABA problem)
  • ZFifo : lockfree fifo implementation (probably broken)
  • ZcFifo : lockfree fifo implementation using chan based freelist (crashes)
  • ZrFifo : lockfree fifo implementation using ring.Ring based freelist (probably broken)
  • RmLifo : ring.Ring based lifo using mutex for locking
  • RmFifo : ring.Ring based fifo using mutex for locking
  • SmLifo : slice based lifo using mutex for locking
  • SmFifo : slice based fifo using mutex for locking

Tests:

  1. Single threaded
  2. Add N, Remove N
  3. N times (Add 1, Remove 1)
  4. N/2 times (Add 2, Remove 1), Remove N/2
  5. Add N/2, N/2 times (Add 1, Remove 2)

ZcFifo was excluded due to crash.

General recommendation use chan if it suits otherwise use slice + "chan as a lock".

Documentation

Overview

implements fifo using a channel

implements locking queues, using list and mutex

implements locking queues, using list and mutex

implements locking queues, using list and channel

implements locking queues, using list and mutex

implements locking queues, using list and mutex

implements locking queues, using list and mutex

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CFifo

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

func NewChanFifo

func NewChanFifo(size int) *CFifo

func (*CFifo) Dequeue

func (q *CFifo) Dequeue() (value interface{}, ok bool)

func (*CFifo) Enqueue

func (q *CFifo) Enqueue(value interface{})

type LCFifo

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

func NewListCFifo

func NewListCFifo() *LCFifo

func (*LCFifo) Dequeue

func (q *LCFifo) Dequeue() (interface{}, bool)

func (*LCFifo) Enqueue

func (q *LCFifo) Enqueue(value interface{})

type LCLifo

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

func NewListCLifo

func NewListCLifo() *LCLifo

func (*LCLifo) Dequeue

func (q *LCLifo) Dequeue() (interface{}, bool)

func (*LCLifo) Enqueue

func (q *LCLifo) Enqueue(value interface{})

type LFifo

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

func NewListFifo

func NewListFifo() *LFifo

func (*LFifo) Dequeue

func (q *LFifo) Dequeue() (interface{}, bool)

func (*LFifo) Enqueue

func (q *LFifo) Enqueue(value interface{})

type LLifo

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

func NewListLifo

func NewListLifo() *LLifo

func (*LLifo) Dequeue

func (q *LLifo) Dequeue() (interface{}, bool)

func (*LLifo) Enqueue

func (q *LLifo) Enqueue(value interface{})

type PcFifo

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

func NewPcFifo

func NewPcFifo() *PcFifo

func (*PcFifo) Dequeue

func (q *PcFifo) Dequeue() (value interface{}, ok bool)

func (*PcFifo) Enqueue

func (q *PcFifo) Enqueue(value interface{})

type PcLifo

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

func NewPcLifo

func NewPcLifo() *PcLifo

func (*PcLifo) Dequeue

func (q *PcLifo) Dequeue() (interface{}, bool)

func (*PcLifo) Enqueue

func (q *PcLifo) Enqueue(value interface{})

type PmFifo

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

func NewPmFifo

func NewPmFifo() *PmFifo

func (*PmFifo) Dequeue

func (q *PmFifo) Dequeue() (value interface{}, ok bool)

func (*PmFifo) Enqueue

func (q *PmFifo) Enqueue(value interface{})

type PmLifo

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

func NewPmLifo

func NewPmLifo() *PmLifo

func (*PmLifo) Dequeue

func (q *PmLifo) Dequeue() (interface{}, bool)

func (*PmLifo) Enqueue

func (q *PmLifo) Enqueue(value interface{})

type Queue

type Queue interface {
	Enqueue(value interface{})
	Dequeue() (value interface{}, ok bool)
}

type RcFifo

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

func NewRcFifo

func NewRcFifo() *RcFifo

func (*RcFifo) Dequeue

func (q *RcFifo) Dequeue() (value interface{}, ok bool)

func (*RcFifo) Enqueue

func (q *RcFifo) Enqueue(value interface{})

type RcLifo

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

func NewRcLifo

func NewRcLifo() *RcLifo

func (*RcLifo) Dequeue

func (q *RcLifo) Dequeue() (value interface{}, ok bool)

func (*RcLifo) Enqueue

func (q *RcLifo) Enqueue(value interface{})

type RmFifo

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

func NewRmFifo

func NewRmFifo() *RmFifo

func (*RmFifo) Dequeue

func (q *RmFifo) Dequeue() (value interface{}, ok bool)

func (*RmFifo) Enqueue

func (q *RmFifo) Enqueue(value interface{})

type RmLifo

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

func NewRmLifo

func NewRmLifo() *RmLifo

func (*RmLifo) Dequeue

func (q *RmLifo) Dequeue() (value interface{}, ok bool)

func (*RmLifo) Enqueue

func (q *RmLifo) Enqueue(value interface{})

type ScFifo

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

func NewScFifo

func NewScFifo() *ScFifo

func (*ScFifo) Dequeue

func (q *ScFifo) Dequeue() (interface{}, bool)

func (*ScFifo) Enqueue

func (q *ScFifo) Enqueue(value interface{})

type ScLifo

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

func NewScLifo

func NewScLifo() *ScLifo

func (*ScLifo) Dequeue

func (q *ScLifo) Dequeue() (interface{}, bool)

func (*ScLifo) Enqueue

func (q *ScLifo) Enqueue(value interface{})

type SmFifo

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

func NewSmFifo

func NewSmFifo() *SmFifo

func (*SmFifo) Dequeue

func (q *SmFifo) Dequeue() (interface{}, bool)

func (*SmFifo) Enqueue

func (q *SmFifo) Enqueue(value interface{})

type SmLifo

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

func NewSmLifo

func NewSmLifo() *SmLifo

func (*SmLifo) Dequeue

func (q *SmLifo) Dequeue() (interface{}, bool)

func (*SmLifo) Enqueue

func (q *SmLifo) Enqueue(value interface{})

type ZFifo

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

func NewZFifo

func NewZFifo() *ZFifo

New returns an initialized queue

func (*ZFifo) Dequeue

func (q *ZFifo) Dequeue() (value interface{}, ok bool)

Dequeue returns the value at the head of the queue and true, or if the queue is empty, it returns a nil value and false

func (*ZFifo) Enqueue

func (q *ZFifo) Enqueue(value interface{})

Enqueue inserts the value at the tail of the queue

type ZFifoFreechan

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

func NewZFifoFreechan

func NewZFifoFreechan() *ZFifoFreechan

New returns an initialized queue

func (*ZFifoFreechan) Dequeue

func (q *ZFifoFreechan) Dequeue() (value interface{}, ok bool)

Dequeue returns the value at the head of the queue and true, or if the queue is empty, it returns a nil value and false

func (*ZFifoFreechan) Enqueue

func (q *ZFifoFreechan) Enqueue(value interface{})

Enqueue inserts the value at the tail of the queue

type ZFifoFreering

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

func NewZFifoFreering

func NewZFifoFreering() *ZFifoFreering

func (*ZFifoFreering) Dequeue

func (q *ZFifoFreering) Dequeue() (value interface{}, ok bool)

Dequeue returns the value at the head of the queue and true, or if the queue is empty, it returns a nil value and false

func (*ZFifoFreering) Enqueue

func (q *ZFifoFreering) Enqueue(value interface{})

Enqueue inserts the value at the tail of the queue

type ZLifo

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

func NewZLifo

func NewZLifo() *ZLifo

func (*ZLifo) Dequeue

func (q *ZLifo) Dequeue() (value interface{}, ok bool)

func (*ZLifo) Enqueue

func (q *ZLifo) Enqueue(value interface{})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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