(b *testing.B, program string)
| 117 | } |
| 118 | |
| 119 | func 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 | |
| 137 | func BenchmarkSort(b *testing.B) { benchmarkSort(b, "table.sort(a)") } |
| 138 | func BenchmarkSort2(b *testing.B) { |
no test coverage detected