MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / BenchmarkNewFromElements

Function BenchmarkNewFromElements

math/matrix/matrix_test.go:187–202  ·  view source on GitHub ↗

BenchmarkNewFromElements benchmarks the NewFromElements function.

(b *testing.B)

Source from the content-addressed store, hash-verified

185
186// BenchmarkNewFromElements benchmarks the NewFromElements function.
187func BenchmarkNewFromElements(b *testing.B) {
188 // Create a sample matrix for benchmarking
189 rows := 100
190 columns := 100
191 elements := make([][]int, rows)
192 for i := range elements {
193 elements[i] = make([]int, columns)
194 for j := range elements[i] {
195 elements[i][j] = i*columns + j // Some arbitrary values
196 }
197 }
198
199 for i := 0; i < b.N; i++ {
200 _, _ = matrix.NewFromElements(elements)
201 }
202}
203
204// BenchmarkGet benchmarks the Get method.
205func BenchmarkGet(b *testing.B) {

Callers

nothing calls this directly

Calls 1

NewFromElementsFunction · 0.92

Tested by

no test coverage detected