(b *testing.B)
| 276 | } |
| 277 | |
| 278 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…