diff options
author | EuAndreh <eu@euandre.org> | 2024-12-27 04:55:33 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-12-27 04:55:33 -0300 |
commit | 2764d269764e5c34c0d94ea58a5544692762560d (patch) | |
tree | b90c4bf1b9905566c00f9a7436c2cc79f1c8d843 /tests/benchmarks | |
parent | Add Makefile and move files to structured folders (diff) | |
download | pds-2764d269764e5c34c0d94ea58a5544692762560d.tar.gz pds-2764d269764e5c34c0d94ea58a5544692762560d.tar.xz |
tests/pds.go: Move benchmarks and examples to separate test files
Diffstat (limited to 'tests/benchmarks')
46 files changed, 611 insertions, 0 deletions
diff --git a/tests/benchmarks/builtin-map-delete/main.go b/tests/benchmarks/builtin-map-delete/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/builtin-map-delete/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/builtin-map-delete/pds.go b/tests/benchmarks/builtin-map-delete/pds.go new file mode 100644 index 0000000..39d8816 --- /dev/null +++ b/tests/benchmarks/builtin-map-delete/pds.go @@ -0,0 +1,27 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + m := map[int]int{} + for i := 0; i < n; i++ { + m[i] = i + } + + for i := 0; i < n; i++ { + delete(m, i) + } +} diff --git a/tests/benchmarks/builtin-map-set/main.go b/tests/benchmarks/builtin-map-set/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/builtin-map-set/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/builtin-map-set/pds.go b/tests/benchmarks/builtin-map-set/pds.go new file mode 100644 index 0000000..0e2ea79 --- /dev/null +++ b/tests/benchmarks/builtin-map-set/pds.go @@ -0,0 +1,23 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + m := map[int]int{} + for i := 0; i < n; i++ { + m[i] = i + } +} diff --git a/tests/benchmarks/builtin-slice-append-int/main.go b/tests/benchmarks/builtin-slice-append-int/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/builtin-slice-append-int/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/builtin-slice-append-int/pds.go b/tests/benchmarks/builtin-slice-append-int/pds.go new file mode 100644 index 0000000..8e4ec9f --- /dev/null +++ b/tests/benchmarks/builtin-slice-append-int/pds.go @@ -0,0 +1,23 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + a := []int{} + for i := 0; i < n; i++ { + a = append(a, i) + } +} diff --git a/tests/benchmarks/builtin-slice-append-interface/main.go b/tests/benchmarks/builtin-slice-append-interface/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/builtin-slice-append-interface/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/builtin-slice-append-interface/pds.go b/tests/benchmarks/builtin-slice-append-interface/pds.go new file mode 100644 index 0000000..8911954 --- /dev/null +++ b/tests/benchmarks/builtin-slice-append-interface/pds.go @@ -0,0 +1,23 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + a := []interface{}{} + for i := 0; i < n; i++ { + a = append(a, i) + } +} diff --git a/tests/benchmarks/list-append/main.go b/tests/benchmarks/list-append/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/list-append/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/list-append/pds.go b/tests/benchmarks/list-append/pds.go new file mode 100644 index 0000000..a9b7690 --- /dev/null +++ b/tests/benchmarks/list-append/pds.go @@ -0,0 +1,23 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + l := NewList[int]() + for i := 0; i < n; i++ { + l = l.Append(i) + } +} diff --git a/tests/benchmarks/list-builder-append/main.go b/tests/benchmarks/list-builder-append/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/list-builder-append/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/list-builder-append/pds.go b/tests/benchmarks/list-builder-append/pds.go new file mode 100644 index 0000000..3357ee6 --- /dev/null +++ b/tests/benchmarks/list-builder-append/pds.go @@ -0,0 +1,23 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + builder := NewListBuilder[int]() + for i := 0; i < n; i++ { + builder.Append(i) + } +} diff --git a/tests/benchmarks/list-builder-prepend/main.go b/tests/benchmarks/list-builder-prepend/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/list-builder-prepend/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/list-builder-prepend/pds.go b/tests/benchmarks/list-builder-prepend/pds.go new file mode 100644 index 0000000..572b6b6 --- /dev/null +++ b/tests/benchmarks/list-builder-prepend/pds.go @@ -0,0 +1,23 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + builder := NewListBuilder[int]() + for i := 0; i < n; i++ { + builder.Prepend(i) + } +} diff --git a/tests/benchmarks/list-builder-set/main.go b/tests/benchmarks/list-builder-set/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/list-builder-set/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/list-builder-set/pds.go b/tests/benchmarks/list-builder-set/pds.go new file mode 100644 index 0000000..4080e22 --- /dev/null +++ b/tests/benchmarks/list-builder-set/pds.go @@ -0,0 +1,27 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + builder := NewListBuilder[int]() + for i := 0; i < n; i++ { + builder.Append(i) + } + + for i := 0; i < n; i++ { + builder.Set(i, i * 10) + } +} diff --git a/tests/benchmarks/list-iterator-backward/main.go b/tests/benchmarks/list-iterator-backward/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/list-iterator-backward/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/list-iterator-backward/pds.go b/tests/benchmarks/list-iterator-backward/pds.go new file mode 100644 index 0000000..6ca51e4 --- /dev/null +++ b/tests/benchmarks/list-iterator-backward/pds.go @@ -0,0 +1,29 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + l := NewList[int]() + for i := 0; i < n; i++ { + l = l.Append(i) + } + + itr := l.Iterator() + itr.Last() + for i := 0; i < n; i++ { + itr.Prev() + } +} diff --git a/tests/benchmarks/list-iterator-forward/main.go b/tests/benchmarks/list-iterator-forward/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/list-iterator-forward/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/list-iterator-forward/pds.go b/tests/benchmarks/list-iterator-forward/pds.go new file mode 100644 index 0000000..6831dad --- /dev/null +++ b/tests/benchmarks/list-iterator-forward/pds.go @@ -0,0 +1,29 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + l := NewList[int]() + for i := 0; i < n; i++ { + l = l.Append(i) + } + + itr := l.Iterator() + itr.First() + for i := 0; i < n; i++ { + itr.Next() + } +} diff --git a/tests/benchmarks/list-prepend/main.go b/tests/benchmarks/list-prepend/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/list-prepend/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/list-prepend/pds.go b/tests/benchmarks/list-prepend/pds.go new file mode 100644 index 0000000..918ff72 --- /dev/null +++ b/tests/benchmarks/list-prepend/pds.go @@ -0,0 +1,23 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + l := NewList[int]() + for i := 0; i < n; i++ { + l = l.Prepend(i) + } +} diff --git a/tests/benchmarks/list-set/main.go b/tests/benchmarks/list-set/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/list-set/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/list-set/pds.go b/tests/benchmarks/list-set/pds.go new file mode 100644 index 0000000..e2d3709 --- /dev/null +++ b/tests/benchmarks/list-set/pds.go @@ -0,0 +1,27 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + l := NewList[int]() + for i := 0; i < n; i++ { + l = l.Append(i) + } + + for i := 0; i < n; i++ { + l = l.Set(i, i * 10) + } +} diff --git a/tests/benchmarks/map-builder-delete/main.go b/tests/benchmarks/map-builder-delete/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/map-builder-delete/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/map-builder-delete/pds.go b/tests/benchmarks/map-builder-delete/pds.go new file mode 100644 index 0000000..a47d07e --- /dev/null +++ b/tests/benchmarks/map-builder-delete/pds.go @@ -0,0 +1,27 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + builder := NewMapBuilder[int, int](nil) + for i := 0; i < n; i++ { + builder.Set(i, i) + } + + for i := 0; i < n; i++ { + builder.Delete(i) + } +} diff --git a/tests/benchmarks/map-builder-set/main.go b/tests/benchmarks/map-builder-set/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/map-builder-set/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/map-builder-set/pds.go b/tests/benchmarks/map-builder-set/pds.go new file mode 100644 index 0000000..d9ff260 --- /dev/null +++ b/tests/benchmarks/map-builder-set/pds.go @@ -0,0 +1,23 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + builder := NewMapBuilder[int, int](nil) + for i := 0; i < n; i++ { + builder.Set(i, i) + } +} diff --git a/tests/benchmarks/map-delete/main.go b/tests/benchmarks/map-delete/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/map-delete/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/map-delete/pds.go b/tests/benchmarks/map-delete/pds.go new file mode 100644 index 0000000..1e2771c --- /dev/null +++ b/tests/benchmarks/map-delete/pds.go @@ -0,0 +1,28 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + builder := NewMapBuilder[int, int](nil) + for i := 0; i < n; i++ { + builder.Set(i, i) + } + + m := builder.Map() + for i := 0; i < n; i++ { + m.Delete(i) // Do not update map, always operate on original + } +} diff --git a/tests/benchmarks/map-iterator/main.go b/tests/benchmarks/map-iterator/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/map-iterator/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/map-iterator/pds.go b/tests/benchmarks/map-iterator/pds.go new file mode 100644 index 0000000..adef8a9 --- /dev/null +++ b/tests/benchmarks/map-iterator/pds.go @@ -0,0 +1,29 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + m := NewMap[int, int](nil) + for i := 0; i < n; i++ { + m = m.Set(i, i) + } + + itr := m.Iterator() + itr.First() + for i := 0; i < n; i++ { + itr.Next() + } +} diff --git a/tests/benchmarks/map-set/main.go b/tests/benchmarks/map-set/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/map-set/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/map-set/pds.go b/tests/benchmarks/map-set/pds.go new file mode 100644 index 0000000..9a57139 --- /dev/null +++ b/tests/benchmarks/map-set/pds.go @@ -0,0 +1,23 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + m := NewMap[int, int](nil) + for i := 0; i < n; i++ { + m = m.Set(i, i) + } +} diff --git a/tests/benchmarks/sortedmap-builder-delete/main.go b/tests/benchmarks/sortedmap-builder-delete/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/sortedmap-builder-delete/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/sortedmap-builder-delete/pds.go b/tests/benchmarks/sortedmap-builder-delete/pds.go new file mode 100644 index 0000000..a4509f1 --- /dev/null +++ b/tests/benchmarks/sortedmap-builder-delete/pds.go @@ -0,0 +1,27 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + builder := NewSortedMapBuilder[int, int](nil) + for i := 0; i < n; i++ { + builder.Set(i, i) + } + + for i := 0; i < n; i++ { + builder.Delete(i) + } +} diff --git a/tests/benchmarks/sortedmap-builder-set/main.go b/tests/benchmarks/sortedmap-builder-set/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/sortedmap-builder-set/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/sortedmap-builder-set/pds.go b/tests/benchmarks/sortedmap-builder-set/pds.go new file mode 100644 index 0000000..a354c42 --- /dev/null +++ b/tests/benchmarks/sortedmap-builder-set/pds.go @@ -0,0 +1,23 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + builder := NewSortedMapBuilder[int, int](nil) + for i := 0; i < n; i++ { + builder.Set(i, i) + } +} diff --git a/tests/benchmarks/sortedmap-delete/main.go b/tests/benchmarks/sortedmap-delete/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/sortedmap-delete/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/sortedmap-delete/pds.go b/tests/benchmarks/sortedmap-delete/pds.go new file mode 100644 index 0000000..fc7642e --- /dev/null +++ b/tests/benchmarks/sortedmap-delete/pds.go @@ -0,0 +1,27 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + m := NewSortedMap[int, int](nil) + for i := 0; i < n; i++ { + m = m.Set(i, i) + } + + for i := 0; i < n; i++ { + m.Delete(i) // Do not update map, always operate on original + } +} diff --git a/tests/benchmarks/sortedmap-iterator-backward/main.go b/tests/benchmarks/sortedmap-iterator-backward/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/sortedmap-iterator-backward/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/sortedmap-iterator-backward/pds.go b/tests/benchmarks/sortedmap-iterator-backward/pds.go new file mode 100644 index 0000000..0aa442e --- /dev/null +++ b/tests/benchmarks/sortedmap-iterator-backward/pds.go @@ -0,0 +1,29 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + m := NewSortedMap[int, int](nil) + for i := 0; i < n; i++ { + m = m.Set(i, i) + } + + itr := m.Iterator() + itr.Last() + for i := 0; i < n; i++ { + itr.Prev() + } +} diff --git a/tests/benchmarks/sortedmap-iterator-forward/main.go b/tests/benchmarks/sortedmap-iterator-forward/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/sortedmap-iterator-forward/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/sortedmap-iterator-forward/pds.go b/tests/benchmarks/sortedmap-iterator-forward/pds.go new file mode 100644 index 0000000..e422034 --- /dev/null +++ b/tests/benchmarks/sortedmap-iterator-forward/pds.go @@ -0,0 +1,29 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + m := NewSortedMap[int, int](nil) + for i := 0; i < n; i++ { + m = m.Set(i, i) + } + + itr := m.Iterator() + itr.First() + for i := 0; i < n; i++ { + itr.Next() + } +} diff --git a/tests/benchmarks/sortedmap-set/main.go b/tests/benchmarks/sortedmap-set/main.go new file mode 120000 index 0000000..f67563d --- /dev/null +++ b/tests/benchmarks/sortedmap-set/main.go @@ -0,0 +1 @@ +../../main.go
\ No newline at end of file diff --git a/tests/benchmarks/sortedmap-set/pds.go b/tests/benchmarks/sortedmap-set/pds.go new file mode 100644 index 0000000..a9837b1 --- /dev/null +++ b/tests/benchmarks/sortedmap-set/pds.go @@ -0,0 +1,23 @@ +package pds + +import ( + "flag" +) + + + +var nFlag = flag.Int( + "n", + 1_000, + "The number of iterations to execute", +) + +func MainTest() { + flag.Parse() + n := *nFlag + + m := NewSortedMap[int, int](nil) + for i := 0; i < n; i++ { + m = m.Set(i, i) + } +} |