Skip to content
Open
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
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ results:
@echo "Create results folder..."
@mkdir results

calls: results
calls/func.plugin.so: calls/plugin/nop.go
@go build -buildmode=plugin -o $@ $<

calls: results calls/func.plugin.so
@rm -rf ./results/calls.*
@go test ./calls -benchmem -bench=. | tee ./results/calls.log

Expand Down
24 changes: 24 additions & 0 deletions calls/call_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
package calls

import (
"plugin"
"testing"

"github.com/kellabyte/go-benchmarks/calls/asm"
)

var pluginNop func()

func init() {
plug, err := plugin.Open("func.plugin.so")
if err != nil {
panic(err)
}

symNop, err := plug.Lookup("Nop")
if err != nil {
panic(err)
}

pluginNop = symNop.(func())
}

func BenchmarkCGO(b *testing.B) {
for i := 0; i < b.N; i++ {
CNop()
Expand All @@ -20,6 +37,13 @@ func BenchmarkGo(b *testing.B) {
}
}

func BenchmarkPlugin(b *testing.B) {
for i := 0; i < b.N; i++ {
pluginNop()
b.SetBytes(1)
}
}

func BenchmarkAsm(b *testing.B) {
for i := 0; i < b.N; i++ {
asm.Nop()
Expand Down
7 changes: 7 additions & 0 deletions calls/plugin/nop.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

func Nop() {}

func main() {

}