bench_traversal_test.go 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. package goquery
  2. import (
  3. "testing"
  4. )
  5. func BenchmarkFind(b *testing.B) {
  6. var n int
  7. for i := 0; i < b.N; i++ {
  8. if n == 0 {
  9. n = DocB().Find("dd").Length()
  10. } else {
  11. DocB().Find("dd")
  12. }
  13. }
  14. if n != 41 {
  15. b.Fatalf("want 41, got %d", n)
  16. }
  17. }
  18. func BenchmarkFindWithinSelection(b *testing.B) {
  19. var n int
  20. b.StopTimer()
  21. sel := DocW().Find("ul")
  22. b.StartTimer()
  23. for i := 0; i < b.N; i++ {
  24. if n == 0 {
  25. n = sel.Find("a[class]").Length()
  26. } else {
  27. sel.Find("a[class]")
  28. }
  29. }
  30. if n != 39 {
  31. b.Fatalf("want 39, got %d", n)
  32. }
  33. }
  34. func BenchmarkFindSelection(b *testing.B) {
  35. var n int
  36. b.StopTimer()
  37. sel := DocW().Find("ul")
  38. sel2 := DocW().Find("span")
  39. b.StartTimer()
  40. for i := 0; i < b.N; i++ {
  41. if n == 0 {
  42. n = sel.FindSelection(sel2).Length()
  43. } else {
  44. sel.FindSelection(sel2)
  45. }
  46. }
  47. if n != 73 {
  48. b.Fatalf("want 73, got %d", n)
  49. }
  50. }
  51. func BenchmarkFindNodes(b *testing.B) {
  52. var n int
  53. b.StopTimer()
  54. sel := DocW().Find("ul")
  55. sel2 := DocW().Find("span")
  56. nodes := sel2.Nodes
  57. b.StartTimer()
  58. for i := 0; i < b.N; i++ {
  59. if n == 0 {
  60. n = sel.FindNodes(nodes...).Length()
  61. } else {
  62. sel.FindNodes(nodes...)
  63. }
  64. }
  65. if n != 73 {
  66. b.Fatalf("want 73, got %d", n)
  67. }
  68. }
  69. func BenchmarkContents(b *testing.B) {
  70. var n int
  71. b.StopTimer()
  72. sel := DocW().Find(".toclevel-1")
  73. b.StartTimer()
  74. for i := 0; i < b.N; i++ {
  75. if n == 0 {
  76. n = sel.Contents().Length()
  77. } else {
  78. sel.Contents()
  79. }
  80. }
  81. if n != 16 {
  82. b.Fatalf("want 16, got %d", n)
  83. }
  84. }
  85. func BenchmarkContentsFiltered(b *testing.B) {
  86. var n int
  87. b.StopTimer()
  88. sel := DocW().Find(".toclevel-1")
  89. b.StartTimer()
  90. for i := 0; i < b.N; i++ {
  91. if n == 0 {
  92. n = sel.ContentsFiltered("a[href=\"#Examples\"]").Length()
  93. } else {
  94. sel.ContentsFiltered("a[href=\"#Examples\"]")
  95. }
  96. }
  97. if n != 1 {
  98. b.Fatalf("want 1, got %d", n)
  99. }
  100. }
  101. func BenchmarkChildren(b *testing.B) {
  102. var n int
  103. b.StopTimer()
  104. sel := DocW().Find(".toclevel-2")
  105. b.StartTimer()
  106. for i := 0; i < b.N; i++ {
  107. if n == 0 {
  108. n = sel.Children().Length()
  109. } else {
  110. sel.Children()
  111. }
  112. }
  113. if n != 2 {
  114. b.Fatalf("want 2, got %d", n)
  115. }
  116. }
  117. func BenchmarkChildrenFiltered(b *testing.B) {
  118. var n int
  119. b.StopTimer()
  120. sel := DocW().Find("h3")
  121. b.StartTimer()
  122. for i := 0; i < b.N; i++ {
  123. if n == 0 {
  124. n = sel.ChildrenFiltered(".editsection").Length()
  125. } else {
  126. sel.ChildrenFiltered(".editsection")
  127. }
  128. }
  129. if n != 2 {
  130. b.Fatalf("want 2, got %d", n)
  131. }
  132. }
  133. func BenchmarkParent(b *testing.B) {
  134. var n int
  135. b.StopTimer()
  136. sel := DocW().Find("li")
  137. b.StartTimer()
  138. for i := 0; i < b.N; i++ {
  139. if n == 0 {
  140. n = sel.Parent().Length()
  141. } else {
  142. sel.Parent()
  143. }
  144. }
  145. if n != 55 {
  146. b.Fatalf("want 55, got %d", n)
  147. }
  148. }
  149. func BenchmarkParentFiltered(b *testing.B) {
  150. var n int
  151. b.StopTimer()
  152. sel := DocW().Find("li")
  153. b.StartTimer()
  154. for i := 0; i < b.N; i++ {
  155. if n == 0 {
  156. n = sel.ParentFiltered("ul[id]").Length()
  157. } else {
  158. sel.ParentFiltered("ul[id]")
  159. }
  160. }
  161. if n != 4 {
  162. b.Fatalf("want 4, got %d", n)
  163. }
  164. }
  165. func BenchmarkParents(b *testing.B) {
  166. var n int
  167. b.StopTimer()
  168. sel := DocW().Find("th a")
  169. b.StartTimer()
  170. for i := 0; i < b.N; i++ {
  171. if n == 0 {
  172. n = sel.Parents().Length()
  173. } else {
  174. sel.Parents()
  175. }
  176. }
  177. if n != 73 {
  178. b.Fatalf("want 73, got %d", n)
  179. }
  180. }
  181. func BenchmarkParentsFiltered(b *testing.B) {
  182. var n int
  183. b.StopTimer()
  184. sel := DocW().Find("th a")
  185. b.StartTimer()
  186. for i := 0; i < b.N; i++ {
  187. if n == 0 {
  188. n = sel.ParentsFiltered("tr").Length()
  189. } else {
  190. sel.ParentsFiltered("tr")
  191. }
  192. }
  193. if n != 18 {
  194. b.Fatalf("want 18, got %d", n)
  195. }
  196. }
  197. func BenchmarkParentsUntil(b *testing.B) {
  198. var n int
  199. b.StopTimer()
  200. sel := DocW().Find("th a")
  201. b.StartTimer()
  202. for i := 0; i < b.N; i++ {
  203. if n == 0 {
  204. n = sel.ParentsUntil("table").Length()
  205. } else {
  206. sel.ParentsUntil("table")
  207. }
  208. }
  209. if n != 52 {
  210. b.Fatalf("want 52, got %d", n)
  211. }
  212. }
  213. func BenchmarkParentsUntilSelection(b *testing.B) {
  214. var n int
  215. b.StopTimer()
  216. sel := DocW().Find("th a")
  217. sel2 := DocW().Find("#content")
  218. b.StartTimer()
  219. for i := 0; i < b.N; i++ {
  220. if n == 0 {
  221. n = sel.ParentsUntilSelection(sel2).Length()
  222. } else {
  223. sel.ParentsUntilSelection(sel2)
  224. }
  225. }
  226. if n != 70 {
  227. b.Fatalf("want 70, got %d", n)
  228. }
  229. }
  230. func BenchmarkParentsUntilNodes(b *testing.B) {
  231. var n int
  232. b.StopTimer()
  233. sel := DocW().Find("th a")
  234. sel2 := DocW().Find("#content")
  235. nodes := sel2.Nodes
  236. b.StartTimer()
  237. for i := 0; i < b.N; i++ {
  238. if n == 0 {
  239. n = sel.ParentsUntilNodes(nodes...).Length()
  240. } else {
  241. sel.ParentsUntilNodes(nodes...)
  242. }
  243. }
  244. if n != 70 {
  245. b.Fatalf("want 70, got %d", n)
  246. }
  247. }
  248. func BenchmarkParentsFilteredUntil(b *testing.B) {
  249. var n int
  250. b.StopTimer()
  251. sel := DocW().Find(".toclevel-1 a")
  252. b.StartTimer()
  253. for i := 0; i < b.N; i++ {
  254. if n == 0 {
  255. n = sel.ParentsFilteredUntil(":nth-child(1)", "ul").Length()
  256. } else {
  257. sel.ParentsFilteredUntil(":nth-child(1)", "ul")
  258. }
  259. }
  260. if n != 2 {
  261. b.Fatalf("want 2, got %d", n)
  262. }
  263. }
  264. func BenchmarkParentsFilteredUntilSelection(b *testing.B) {
  265. var n int
  266. b.StopTimer()
  267. sel := DocW().Find(".toclevel-1 a")
  268. sel2 := DocW().Find("ul")
  269. b.StartTimer()
  270. for i := 0; i < b.N; i++ {
  271. if n == 0 {
  272. n = sel.ParentsFilteredUntilSelection(":nth-child(1)", sel2).Length()
  273. } else {
  274. sel.ParentsFilteredUntilSelection(":nth-child(1)", sel2)
  275. }
  276. }
  277. if n != 2 {
  278. b.Fatalf("want 2, got %d", n)
  279. }
  280. }
  281. func BenchmarkParentsFilteredUntilNodes(b *testing.B) {
  282. var n int
  283. b.StopTimer()
  284. sel := DocW().Find(".toclevel-1 a")
  285. sel2 := DocW().Find("ul")
  286. nodes := sel2.Nodes
  287. b.StartTimer()
  288. for i := 0; i < b.N; i++ {
  289. if n == 0 {
  290. n = sel.ParentsFilteredUntilNodes(":nth-child(1)", nodes...).Length()
  291. } else {
  292. sel.ParentsFilteredUntilNodes(":nth-child(1)", nodes...)
  293. }
  294. }
  295. if n != 2 {
  296. b.Fatalf("want 2, got %d", n)
  297. }
  298. }
  299. func BenchmarkSiblings(b *testing.B) {
  300. var n int
  301. b.StopTimer()
  302. sel := DocW().Find("ul li:nth-child(1)")
  303. b.StartTimer()
  304. for i := 0; i < b.N; i++ {
  305. if n == 0 {
  306. n = sel.Siblings().Length()
  307. } else {
  308. sel.Siblings()
  309. }
  310. }
  311. if n != 293 {
  312. b.Fatalf("want 293, got %d", n)
  313. }
  314. }
  315. func BenchmarkSiblingsFiltered(b *testing.B) {
  316. var n int
  317. b.StopTimer()
  318. sel := DocW().Find("ul li:nth-child(1)")
  319. b.StartTimer()
  320. for i := 0; i < b.N; i++ {
  321. if n == 0 {
  322. n = sel.SiblingsFiltered("[class]").Length()
  323. } else {
  324. sel.SiblingsFiltered("[class]")
  325. }
  326. }
  327. if n != 46 {
  328. b.Fatalf("want 46, got %d", n)
  329. }
  330. }
  331. func BenchmarkNext(b *testing.B) {
  332. var n int
  333. b.StopTimer()
  334. sel := DocW().Find("li:nth-child(1)")
  335. b.StartTimer()
  336. for i := 0; i < b.N; i++ {
  337. if n == 0 {
  338. n = sel.Next().Length()
  339. } else {
  340. sel.Next()
  341. }
  342. }
  343. if n != 49 {
  344. b.Fatalf("want 49, got %d", n)
  345. }
  346. }
  347. func BenchmarkNextFiltered(b *testing.B) {
  348. var n int
  349. b.StopTimer()
  350. sel := DocW().Find("li:nth-child(1)")
  351. b.StartTimer()
  352. for i := 0; i < b.N; i++ {
  353. if n == 0 {
  354. n = sel.NextFiltered("[class]").Length()
  355. } else {
  356. sel.NextFiltered("[class]")
  357. }
  358. }
  359. if n != 6 {
  360. b.Fatalf("want 6, got %d", n)
  361. }
  362. }
  363. func BenchmarkNextAll(b *testing.B) {
  364. var n int
  365. b.StopTimer()
  366. sel := DocW().Find("li:nth-child(3)")
  367. b.StartTimer()
  368. for i := 0; i < b.N; i++ {
  369. if n == 0 {
  370. n = sel.NextAll().Length()
  371. } else {
  372. sel.NextAll()
  373. }
  374. }
  375. if n != 234 {
  376. b.Fatalf("want 234, got %d", n)
  377. }
  378. }
  379. func BenchmarkNextAllFiltered(b *testing.B) {
  380. var n int
  381. b.StopTimer()
  382. sel := DocW().Find("li:nth-child(3)")
  383. b.StartTimer()
  384. for i := 0; i < b.N; i++ {
  385. if n == 0 {
  386. n = sel.NextAllFiltered("[class]").Length()
  387. } else {
  388. sel.NextAllFiltered("[class]")
  389. }
  390. }
  391. if n != 33 {
  392. b.Fatalf("want 33, got %d", n)
  393. }
  394. }
  395. func BenchmarkPrev(b *testing.B) {
  396. var n int
  397. b.StopTimer()
  398. sel := DocW().Find("li:last-child")
  399. b.StartTimer()
  400. for i := 0; i < b.N; i++ {
  401. if n == 0 {
  402. n = sel.Prev().Length()
  403. } else {
  404. sel.Prev()
  405. }
  406. }
  407. if n != 49 {
  408. b.Fatalf("want 49, got %d", n)
  409. }
  410. }
  411. func BenchmarkPrevFiltered(b *testing.B) {
  412. var n int
  413. b.StopTimer()
  414. sel := DocW().Find("li:last-child")
  415. b.StartTimer()
  416. for i := 0; i < b.N; i++ {
  417. if n == 0 {
  418. n = sel.PrevFiltered("[class]").Length()
  419. } else {
  420. sel.PrevFiltered("[class]")
  421. }
  422. }
  423. // There is one more Prev li with a class, compared to Next li with a class
  424. // (confirmed by looking at the HTML, this is ok)
  425. if n != 7 {
  426. b.Fatalf("want 7, got %d", n)
  427. }
  428. }
  429. func BenchmarkPrevAll(b *testing.B) {
  430. var n int
  431. b.StopTimer()
  432. sel := DocW().Find("li:nth-child(4)")
  433. b.StartTimer()
  434. for i := 0; i < b.N; i++ {
  435. if n == 0 {
  436. n = sel.PrevAll().Length()
  437. } else {
  438. sel.PrevAll()
  439. }
  440. }
  441. if n != 78 {
  442. b.Fatalf("want 78, got %d", n)
  443. }
  444. }
  445. func BenchmarkPrevAllFiltered(b *testing.B) {
  446. var n int
  447. b.StopTimer()
  448. sel := DocW().Find("li:nth-child(4)")
  449. b.StartTimer()
  450. for i := 0; i < b.N; i++ {
  451. if n == 0 {
  452. n = sel.PrevAllFiltered("[class]").Length()
  453. } else {
  454. sel.PrevAllFiltered("[class]")
  455. }
  456. }
  457. if n != 6 {
  458. b.Fatalf("want 6, got %d", n)
  459. }
  460. }
  461. func BenchmarkNextUntil(b *testing.B) {
  462. var n int
  463. b.StopTimer()
  464. sel := DocW().Find("li:first-child")
  465. b.StartTimer()
  466. for i := 0; i < b.N; i++ {
  467. if n == 0 {
  468. n = sel.NextUntil(":nth-child(4)").Length()
  469. } else {
  470. sel.NextUntil(":nth-child(4)")
  471. }
  472. }
  473. if n != 84 {
  474. b.Fatalf("want 84, got %d", n)
  475. }
  476. }
  477. func BenchmarkNextUntilSelection(b *testing.B) {
  478. var n int
  479. b.StopTimer()
  480. sel := DocW().Find("h2")
  481. sel2 := DocW().Find("ul")
  482. b.StartTimer()
  483. for i := 0; i < b.N; i++ {
  484. if n == 0 {
  485. n = sel.NextUntilSelection(sel2).Length()
  486. } else {
  487. sel.NextUntilSelection(sel2)
  488. }
  489. }
  490. if n != 42 {
  491. b.Fatalf("want 42, got %d", n)
  492. }
  493. }
  494. func BenchmarkNextUntilNodes(b *testing.B) {
  495. var n int
  496. b.StopTimer()
  497. sel := DocW().Find("h2")
  498. sel2 := DocW().Find("p")
  499. nodes := sel2.Nodes
  500. b.StartTimer()
  501. for i := 0; i < b.N; i++ {
  502. if n == 0 {
  503. n = sel.NextUntilNodes(nodes...).Length()
  504. } else {
  505. sel.NextUntilNodes(nodes...)
  506. }
  507. }
  508. if n != 12 {
  509. b.Fatalf("want 12, got %d", n)
  510. }
  511. }
  512. func BenchmarkPrevUntil(b *testing.B) {
  513. var n int
  514. b.StopTimer()
  515. sel := DocW().Find("li:last-child")
  516. b.StartTimer()
  517. for i := 0; i < b.N; i++ {
  518. if n == 0 {
  519. n = sel.PrevUntil(":nth-child(4)").Length()
  520. } else {
  521. sel.PrevUntil(":nth-child(4)")
  522. }
  523. }
  524. if n != 238 {
  525. b.Fatalf("want 238, got %d", n)
  526. }
  527. }
  528. func BenchmarkPrevUntilSelection(b *testing.B) {
  529. var n int
  530. b.StopTimer()
  531. sel := DocW().Find("h2")
  532. sel2 := DocW().Find("ul")
  533. b.StartTimer()
  534. for i := 0; i < b.N; i++ {
  535. if n == 0 {
  536. n = sel.PrevUntilSelection(sel2).Length()
  537. } else {
  538. sel.PrevUntilSelection(sel2)
  539. }
  540. }
  541. if n != 49 {
  542. b.Fatalf("want 49, got %d", n)
  543. }
  544. }
  545. func BenchmarkPrevUntilNodes(b *testing.B) {
  546. var n int
  547. b.StopTimer()
  548. sel := DocW().Find("h2")
  549. sel2 := DocW().Find("p")
  550. nodes := sel2.Nodes
  551. b.StartTimer()
  552. for i := 0; i < b.N; i++ {
  553. if n == 0 {
  554. n = sel.PrevUntilNodes(nodes...).Length()
  555. } else {
  556. sel.PrevUntilNodes(nodes...)
  557. }
  558. }
  559. if n != 11 {
  560. b.Fatalf("want 11, got %d", n)
  561. }
  562. }
  563. func BenchmarkNextFilteredUntil(b *testing.B) {
  564. var n int
  565. b.StopTimer()
  566. sel := DocW().Find("h2")
  567. b.StartTimer()
  568. for i := 0; i < b.N; i++ {
  569. if n == 0 {
  570. n = sel.NextFilteredUntil("p", "div").Length()
  571. } else {
  572. sel.NextFilteredUntil("p", "div")
  573. }
  574. }
  575. if n != 22 {
  576. b.Fatalf("want 22, got %d", n)
  577. }
  578. }
  579. func BenchmarkNextFilteredUntilSelection(b *testing.B) {
  580. var n int
  581. b.StopTimer()
  582. sel := DocW().Find("h2")
  583. sel2 := DocW().Find("div")
  584. b.StartTimer()
  585. for i := 0; i < b.N; i++ {
  586. if n == 0 {
  587. n = sel.NextFilteredUntilSelection("p", sel2).Length()
  588. } else {
  589. sel.NextFilteredUntilSelection("p", sel2)
  590. }
  591. }
  592. if n != 22 {
  593. b.Fatalf("want 22, got %d", n)
  594. }
  595. }
  596. func BenchmarkNextFilteredUntilNodes(b *testing.B) {
  597. var n int
  598. b.StopTimer()
  599. sel := DocW().Find("h2")
  600. sel2 := DocW().Find("div")
  601. nodes := sel2.Nodes
  602. b.StartTimer()
  603. for i := 0; i < b.N; i++ {
  604. if n == 0 {
  605. n = sel.NextFilteredUntilNodes("p", nodes...).Length()
  606. } else {
  607. sel.NextFilteredUntilNodes("p", nodes...)
  608. }
  609. }
  610. if n != 22 {
  611. b.Fatalf("want 22, got %d", n)
  612. }
  613. }
  614. func BenchmarkPrevFilteredUntil(b *testing.B) {
  615. var n int
  616. b.StopTimer()
  617. sel := DocW().Find("h2")
  618. b.StartTimer()
  619. for i := 0; i < b.N; i++ {
  620. if n == 0 {
  621. n = sel.PrevFilteredUntil("p", "div").Length()
  622. } else {
  623. sel.PrevFilteredUntil("p", "div")
  624. }
  625. }
  626. if n != 20 {
  627. b.Fatalf("want 20, got %d", n)
  628. }
  629. }
  630. func BenchmarkPrevFilteredUntilSelection(b *testing.B) {
  631. var n int
  632. b.StopTimer()
  633. sel := DocW().Find("h2")
  634. sel2 := DocW().Find("div")
  635. b.StartTimer()
  636. for i := 0; i < b.N; i++ {
  637. if n == 0 {
  638. n = sel.PrevFilteredUntilSelection("p", sel2).Length()
  639. } else {
  640. sel.PrevFilteredUntilSelection("p", sel2)
  641. }
  642. }
  643. if n != 20 {
  644. b.Fatalf("want 20, got %d", n)
  645. }
  646. }
  647. func BenchmarkPrevFilteredUntilNodes(b *testing.B) {
  648. var n int
  649. b.StopTimer()
  650. sel := DocW().Find("h2")
  651. sel2 := DocW().Find("div")
  652. nodes := sel2.Nodes
  653. b.StartTimer()
  654. for i := 0; i < b.N; i++ {
  655. if n == 0 {
  656. n = sel.PrevFilteredUntilNodes("p", nodes...).Length()
  657. } else {
  658. sel.PrevFilteredUntilNodes("p", nodes...)
  659. }
  660. }
  661. if n != 20 {
  662. b.Fatalf("want 20, got %d", n)
  663. }
  664. }
  665. func BenchmarkClosest(b *testing.B) {
  666. var n int
  667. b.StopTimer()
  668. sel := Doc().Find(".container-fluid")
  669. b.StartTimer()
  670. for i := 0; i < b.N; i++ {
  671. if n == 0 {
  672. n = sel.Closest(".pvk-content").Length()
  673. } else {
  674. sel.Closest(".pvk-content")
  675. }
  676. }
  677. if n != 2 {
  678. b.Fatalf("want 2, got %d", n)
  679. }
  680. }
  681. func BenchmarkClosestSelection(b *testing.B) {
  682. var n int
  683. b.StopTimer()
  684. sel := Doc().Find(".container-fluid")
  685. sel2 := Doc().Find(".pvk-content")
  686. b.StartTimer()
  687. for i := 0; i < b.N; i++ {
  688. if n == 0 {
  689. n = sel.ClosestSelection(sel2).Length()
  690. } else {
  691. sel.ClosestSelection(sel2)
  692. }
  693. }
  694. if n != 2 {
  695. b.Fatalf("want 2, got %d", n)
  696. }
  697. }
  698. func BenchmarkClosestNodes(b *testing.B) {
  699. var n int
  700. b.StopTimer()
  701. sel := Doc().Find(".container-fluid")
  702. nodes := Doc().Find(".pvk-content").Nodes
  703. b.StartTimer()
  704. for i := 0; i < b.N; i++ {
  705. if n == 0 {
  706. n = sel.ClosestNodes(nodes...).Length()
  707. } else {
  708. sel.ClosestNodes(nodes...)
  709. }
  710. }
  711. if n != 2 {
  712. b.Fatalf("want 2, got %d", n)
  713. }
  714. }