Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
edwingeng committed May 30, 2022
1 parent e37e586 commit d3c704e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2019, Edwin
Copyright (c) 2019-2022, Edwin
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ Deque is a highly optimized double-ended queue.

# Benchmark
```
Benchmark_PushBack/Deque<harden> 100000000 10.3 ns/op 9 B/op 0 allocs/op
Benchmark_PushBack/Deque 20000000 81.3 ns/op 24 B/op 1 allocs/op
Benchmark_PushBack/list.List 5000000 281 ns/op 56 B/op 2 allocs/op
Benchmark_PushFront/Deque<harden> 195840157 7.96 ns/op 9 B/op 0 allocs/op
Benchmark_PushFront/Deque 30000000 70.6 ns/op 24 B/op 1 allocs/op
Benchmark_PushFront/list.List 5000000 276 ns/op 56 B/op 2 allocs/op
Benchmark_Random/Deque<harden> 65623633 17.3 ns/op 0 B/op 0 allocs/op
Benchmark_Random/Deque 50000000 32.1 ns/op 4 B/op 0 allocs/op
Benchmark_Random/list.List 30000000 123 ns/op 28 B/op 1 allocs/op
PushBack/Deque<harden> 100000000 10.3 ns/op 9 B/op 0 allocs/op
PushBack/Deque 20000000 81.3 ns/op 24 B/op 1 allocs/op
PushBack/list.List 5000000 281 ns/op 56 B/op 2 allocs/op
PushFront/Deque<harden> 195840157 8.0 ns/op 9 B/op 0 allocs/op
PushFront/Deque 30000000 70.6 ns/op 24 B/op 1 allocs/op
PushFront/list.List 5000000 276 ns/op 56 B/op 2 allocs/op
Random/Deque<harden> 65623633 17.3 ns/op 0 B/op 0 allocs/op
Random/Deque 50000000 32.1 ns/op 4 B/op 0 allocs/op
Random/list.List 30000000 123 ns/op 28 B/op 1 allocs/op
```

# Usage
Expand Down Expand Up @@ -46,6 +48,3 @@ for i, n := 0, dq.Len(); i < n; i++ {
``` bash
./harden.sh <outputDir> <packageName> [elemType]
```

# Documentation
[https://godoc.org/github.com/edwingeng/deque](https://godoc.org/github.com/edwingeng/deque)
8 changes: 4 additions & 4 deletions benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ func benchNameSuffix() string {
if t == nil {
return ""
}
rex1 := regexp.MustCompile(`[a-zA-Z0-9_]+\.`)
rex1 := regexp.MustCompile(`\w+\.`)
str1 := rex1.ReplaceAllString(t.String(), "")
str2 := strings.ReplaceAll(str1, "interface {}", "interface{}")
str3 := fmt.Sprintf("<%s>", str2)
return str3
}

func Benchmark_PushBack(b *testing.B) {
func BenchmarkPushBack(b *testing.B) {
b.Run("Deque"+benchNameSuffix(), func(b *testing.B) {
dq := NewDeque()
for i := 0; i < b.N; i++ {
Expand All @@ -38,7 +38,7 @@ func Benchmark_PushBack(b *testing.B) {
})
}

func Benchmark_PushFront(b *testing.B) {
func BenchmarkPushFront(b *testing.B) {
b.Run("Deque"+benchNameSuffix(), func(b *testing.B) {
dq := NewDeque()
for i := 0; i < b.N; i++ {
Expand All @@ -53,7 +53,7 @@ func Benchmark_PushFront(b *testing.B) {
})
}

func Benchmark_Random(b *testing.B) {
func BenchmarkRandom(b *testing.B) {
const na = 100000
a := make([]int, na)
for i := 0; i < na; i++ {
Expand Down
2 changes: 1 addition & 1 deletion deque.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sync/atomic"
)

const chunkSize = 255
const chunkSize = 254

var elemDefValue Elem

Expand Down
2 changes: 1 addition & 1 deletion interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Deque interface {
// buf to store the removed values as long as it has enough space.
DequeueManyWithBuffer(max int, buf []Elem) []Elem

// Range iterates all of the values in Deque.
// Range iterates all the values in Deque.
Range(f func(i int, v Elem) bool)

// Peek returns the value at idx
Expand Down

0 comments on commit d3c704e

Please sign in to comment.