Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions benchmarks/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ require (
github.com/d5/tengo/v2 v2.17.0
github.com/dop251/goja v0.0.0-20260311135729-065cd970411c
github.com/siyul-park/minivm v0.0.0
github.com/stretchr/testify v1.11.1
github.com/tetratelabs/wazero v1.11.0
github.com/yuin/gopher-lua v1.1.2
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dlclark/regexp2 v1.11.4 // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/text v0.3.8 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/siyul-park/minivm => ../
2 changes: 2 additions & 0 deletions benchmarks/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
41 changes: 41 additions & 0 deletions benchmarks/programs_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package bench

import (
"context"
"testing"

"github.com/stretchr/testify/require"

"github.com/siyul-park/minivm/interp"
"github.com/siyul-park/minivm/types"
)

func TestFib(t *testing.T) {
t.Run("base case returns input", func(t *testing.T) {
ctx := context.Background()
i := interp.New(Fib(1))
defer i.Close()

err := i.Run(ctx)
require.NoError(t, err)

got, err := i.Pop()
require.NoError(t, err)
require.Equal(t, types.I32(1), got)
require.Equal(t, 0, i.Len())
})

t.Run("recursive case returns fibonacci value", func(t *testing.T) {
ctx := context.Background()
i := interp.New(Fib(7))
defer i.Close()

err := i.Run(ctx)
require.NoError(t, err)

got, err := i.Pop()
require.NoError(t, err)
require.Equal(t, types.I32(13), got)
require.Equal(t, 0, i.Len())
})
}
Loading