Skip to content

Commit

Permalink
♻️ refactor: move bench and old func to bench a dir
Browse files Browse the repository at this point in the history
Signed-off-by: Adrien Kara <[email protected]>
  • Loading branch information
IGLOU-EU committed Feb 11, 2025
1 parent 749befc commit 4dc1d3e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion old_wildcard_test.go → benchmark/old_wildcard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* limitations under the License.
*/

package wildcard_test
package wildcard_bench

// MatchSimple - finds whether the text matches/satisfies the pattern string.
// supports only '*' wildcard in the pattern.
Expand Down
37 changes: 30 additions & 7 deletions wildcard_bench_test.go → benchmark/wildcard_bench_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wildcard_test
package wildcard_bench

import (
"fmt"
Expand All @@ -11,7 +11,7 @@ import (

var TestSet = []struct {
pattern string
name string
input string
}{
{"", "These aren't the wildcard you're looking for"},
{"These aren't the wildcard you're looking for", ""},
Expand All @@ -25,7 +25,7 @@ func BenchmarkRegex(b *testing.B) {
for i, t := range TestSet {
b.Run(fmt.Sprint(i), func(b *testing.B) {
for i := 0; i < b.N; i++ {
regexp.MatchString(t.pattern, t.name)
regexp.MatchString(t.pattern, t.input)
}
})
}
Expand All @@ -35,7 +35,7 @@ func BenchmarkFilepath(b *testing.B) {
for i, t := range TestSet {
b.Run(fmt.Sprint(i), func(b *testing.B) {
for i := 0; i < b.N; i++ {
filepath.Match(t.pattern, t.name)
filepath.Match(t.pattern, t.input)
}
})
}
Expand All @@ -45,7 +45,7 @@ func BenchmarkOldMatchSimple(b *testing.B) {
for i, t := range TestSet {
b.Run(fmt.Sprint(i), func(b *testing.B) {
for i := 0; i < b.N; i++ {
Old_MatchSimple(t.pattern, t.name)
Old_MatchSimple(t.pattern, t.input)
}
})
}
Expand All @@ -55,7 +55,7 @@ func BenchmarkOldMatch(b *testing.B) {
for i, t := range TestSet {
b.Run(fmt.Sprint(i), func(b *testing.B) {
for i := 0; i < b.N; i++ {
Old_Match(t.pattern, t.name)
Old_Match(t.pattern, t.input)
}
})
}
Expand All @@ -65,7 +65,30 @@ func BenchmarkMatch(b *testing.B) {
for i, t := range TestSet {
b.Run(fmt.Sprint(i), func(b *testing.B) {
for i := 0; i < b.N; i++ {
wildcard.Match(t.pattern, t.name)
wildcard.Match(t.pattern, t.input)
}
})
}
}

func BenchmarkMatchByRune(b *testing.B) {
for i, t := range TestSet {
b.Run(fmt.Sprint(i), func(b *testing.B) {
for i := 0; i < b.N; i++ {
wildcard.MatchByRune(t.pattern, t.input)
}
})
}
}

func BenchmarkMatchFromByte(b *testing.B) {
for i, t := range TestSet {
pattern := []byte(t.pattern)
input := []byte(t.input)

b.Run(fmt.Sprint(i), func(b *testing.B) {
for i := 0; i < b.N; i++ {
wildcard.MatchFromByte(pattern, input)
}
})
}
Expand Down

0 comments on commit 4dc1d3e

Please sign in to comment.