MCPcopy Index your code
hub / github.com/Shopify/go-lua / benchmarkSort

Function benchmarkSort

vm_test.go:119–135  ·  view source on GitHub ↗
(b *testing.B, program string)

Source from the content-addressed store, hash-verified

117}
118
119func benchmarkSort(b *testing.B, program string) {
120 l := NewState()
121 OpenLibraries(l)
122 s := `a = {}
123 for i=1,%d do
124 a[i] = math.random()
125 end`
126 LoadString(l, fmt.Sprintf(s, b.N))
127 if err := l.ProtectedCall(0, 0, 0); err != nil {
128 b.Error(err.Error())
129 }
130 LoadString(l, program)
131 b.ResetTimer()
132 if err := l.ProtectedCall(0, 0, 0); err != nil {
133 b.Error(err.Error())
134 }
135}
136
137func BenchmarkSort(b *testing.B) { benchmarkSort(b, "table.sort(a)") }
138func BenchmarkSort2(b *testing.B) {

Callers 2

BenchmarkSortFunction · 0.85
BenchmarkSort2Function · 0.85

Calls 5

ProtectedCallMethod · 0.95
NewStateFunction · 0.85
OpenLibrariesFunction · 0.85
LoadStringFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected