Skip to content

Instantly share code, notes, and snippets.

@dylanahsmith
Created July 8, 2021 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dylanahsmith/33d4ea9e93351f8750c0614a83aa0248 to your computer and use it in GitHub Desktop.
Save dylanahsmith/33d4ea9e93351f8750c0614a83aa0248 to your computer and use it in GitHub Desktop.
$ go build main.go
$ go test -bench .
goos: darwin
goarch: amd64
pkg: tmp/v8go/spawnv8bench
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
BenchmarkNewIsolate-12 574 2011384 ns/op
BenchmarkSpawn-12 241 4901969 ns/op
package main
func main() {
}
package main_test
import (
"testing"
"os/exec"
"rogchap.com/v8go"
)
func BenchmarkNewIsolate(b *testing.B) {
for bIdx := 0; bIdx < b.N; bIdx++ {
iso, err := v8go.NewIsolate()
if err != nil { panic(err) }
iso.Dispose()
}
}
func BenchmarkSpawn(b *testing.B) {
for i := 0; i < b.N; i++ {
cmd := exec.Command("./main")
err := cmd.Run()
if err != nil {
panic(err)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment