MCPcopy Create free account
hub / github.com/antchfx/xpath / Benchmark_GetHashCode

Function Benchmark_GetHashCode

xpath_function_test.go:278–309  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

276}
277
278func Benchmark_GetHashCode(b *testing.B) {
279 // Create a more complex test node that will actually go through the full getHashCode paths
280 doc := createNavigator(book_example)
281 doc.MoveToRoot()
282 doc.MoveToChild() // Move to the first element
283 doc.MoveToChild() // Deeper
284 // Find a node with attributes
285 var node NodeNavigator
286 for {
287 if doc.NodeType() == AttributeNode || doc.NodeType() == TextNode || doc.NodeType() == CommentNode {
288 node = doc.Copy()
289 break
290 }
291 if !doc.MoveToNext() {
292 if !doc.MoveToChild() {
293 // If we can't find a suitable node, default to using the first element
294 doc.MoveToRoot()
295 doc.MoveToChild()
296 node = doc.Copy()
297 break
298 }
299 }
300 }
301
302 b.Run("getHashCode", func(b *testing.B) {
303 b.ReportAllocs()
304 for i := 0; i < b.N; i++ {
305 n := node.Copy()
306 _ = getHashCode(n)
307 }
308 })
309}

Callers

nothing calls this directly

Calls 7

CopyMethod · 0.95
createNavigatorFunction · 0.85
getHashCodeFunction · 0.85
MoveToRootMethod · 0.65
MoveToChildMethod · 0.65
NodeTypeMethod · 0.65
MoveToNextMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…