Skip to content

Commit

Permalink
Remove redundant listFolders call
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed Mar 11, 2024
1 parent 42b10a9 commit 6840b27
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 34 deletions.
59 changes: 27 additions & 32 deletions tests/evm_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,41 @@ const (
)

func BenchmarkEVM(b *testing.B) {
folders, err := listFolders([]string{benchmarksDir})
files, err := listFiles(benchmarksDir, testsExtension)
require.NoError(b, err)

for _, folder := range folders {
files, err := listFiles(folder, testsExtension)
require.NoError(b, err)
for _, file := range files {
name := filepath.ToSlash(strings.TrimPrefix(strings.TrimSuffix(file, testsExtension), benchmarksDir+string(filepath.Separator)))

for _, file := range files {
name := filepath.ToSlash(strings.TrimPrefix(strings.TrimSuffix(file, testsExtension), folder+string(filepath.Separator)))
b.Run(name, func(b *testing.B) {
data, err := os.ReadFile(file)
require.NoError(b, err)

b.Run(name, func(b *testing.B) {
data, err := os.ReadFile(file)
require.NoError(b, err)
var testCases map[string]testCase
if err = json.Unmarshal(data, &testCases); err != nil {
b.Fatalf("failed to unmarshal %s: %v", file, err)
}

var testCases map[string]testCase
if err = json.Unmarshal(data, &testCases); err != nil {
b.Fatalf("failed to unmarshal %s: %v", file, err)
}
for _, tc := range testCases {
for fork, postState := range tc.Post {
forks, exists := Forks[fork]
if !exists {
b.Logf("%s fork is not supported, skipping test case.", fork)
continue
}

for _, tc := range testCases {
for fork, postState := range tc.Post {
forks, exists := Forks[fork]
if !exists {
b.Logf("%s fork is not supported, skipping test case.", fork)
continue
}

fc := &forkConfig{name: fork, forks: forks}

for idx, postStateEntry := range postState {
key := fmt.Sprintf("%s/%d", fork, idx)
b.Run(key, func(b *testing.B) {
err := runBenchmarkTest(b, tc, fc, postStateEntry)
require.NoError(b, err, fmt.Sprintf("test %s (case#%d) execution failed", name, idx))
})
}
fc := &forkConfig{name: fork, forks: forks}

for idx, postStateEntry := range postState {
key := fmt.Sprintf("%s/%d", fork, idx)
b.Run(key, func(b *testing.B) {
err := runBenchmarkTest(b, tc, fc, postStateEntry)
require.NoError(b, err, fmt.Sprintf("test %s (case#%d) execution failed", name, idx))
})
}
}
})
}
}
})
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/state_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,12 +649,12 @@ func listFolders(paths []string) ([]string, error) {
func listFiles(folder string, extensions ...string) ([]string, error) {
var files []string

err := filepath.WalkDir(folder, func(path string, d fs.DirEntry, err error) error {
err := filepath.Walk(folder, func(path string, info fs.FileInfo, err error) error {
if err != nil {
return err
}

if d.IsDir() {
if info.IsDir() {
return nil
}

Expand Down

0 comments on commit 6840b27

Please sign in to comment.