labs08

package
v0.0.0-...-6c2044b Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

README

同labs07,区别是用slice替代链表结构。

试验结果:

dada-imac:labs dada$ go test -test.bench="." labs08
PASS
Benchmark_Loop1    2000000           837 ns/op
Benchmark_Loop2    1000000          2671 ns/op
Benchmark_Loop3     100000         15072 ns/op
Benchmark_Loop4      10000        130577 ns/op
Benchmark_Loop5       5000        606500 ns/op
Benchmark_Loop6     500000          7145 ns/op
ok  	labs08	    4.959s
dada-imac:labs dada$ go test -test.bench="." labs07
PASS
Benchmark_Loop1    500000          4386 ns/op
Benchmark_Loop2    500000          5206 ns/op
Benchmark_Loop3    100000         14821 ns/op
Benchmark_Loop4     10000        135384 ns/op
Benchmark_Loop5      5000        607735 ns/op
Benchmark_Loop6    500000          7067 ns/op
ok  	labs07	14.618s    

结论:简单循环slice明显更快,但是加入查询后, slice的优势就可以忽略不计了。

Documentation

Index

Constants

View Source
const OP_EQ = 0 // ==

operator

View Source
const TP_INT = 0 // int

type

Variables

This section is empty.

Functions

This section is empty.

Types

type BigStruct

type BigStruct struct {
	C01 int
	C02 int
	C03 int
	C04 int
	C05 int
	C06 int
	C07 int
	C08 int
	C09 int
	C10 int
	C11 int
	C12 int
	C13 int
	C14 int
	C15 int
	C16 int
	C17 int
	C18 int
	C19 int
	C20 int
	C21 int
	C22 int
	C23 int
	C24 int
	C25 int
	C26 int
	C27 int
	C28 int
	C29 int
	C30 int
	// contains filtered or unexported fields
}

type Condition

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

func (*Condition) Match

func (c *Condition) Match(n uintptr) bool

type Query

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

func NewQuery

func NewQuery(name string, operator string, value int) *Query

func (*Query) Match

func (q *Query) Match(n *BigStruct) bool

Jump to

Keyboard shortcuts

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