Posted to tcl by de at Thu Jan 21 14:00:43 GMT 2021view raw
- #load ./libtdom0.9.3.so
- package require tdom 0.9.3
- set nrNoise 10
- set noiseElement "elementNoise"
- set nrMeat 40
- set meatPrefix "element"
- set size 1000000
- proc generateInput {nrNoise noiseElement nrMeat meatPrefix size} {
- set xml "<doc>"
- set names [list]
- for {set i 0} {$i < $nrMeat} {incr i} {
- lappend names $meatPrefix$i
- }
- while {[string length $xml] < $size} {
- for {set i 0} {$i < $nrMeat} {incr i} {
- append xml [string repeat "<$noiseElement/>" $nrNoise]
- append xml "<$meatPrefix$i/>\n"
- }
- }
- append xml "</doc>"
- return [list $xml $names]
- }
- proc testnames {xml names} {
- tdom::pullparser pp
- pp input $xml
- set result [list]
- pp next
- puts "-names [time {
- while {[pp state] ne "END_DOCUMENT"} {
- lappend result [pp tag]
- pp find-element -names $names
- }
- }]"
- pp delete
- }
- proc testnameshashed {xml names} {
- tdom::pullparser pp
- pp input $xml
- set result [list]
- pp next
- puts "-names hashed [time {
- while {[pp state] ne "END_DOCUMENT"} {
- lappend result [pp tag]
- pp find-element -names $names -hash
- }
- }]"
- pp delete
- }
- proc testnameshashednext {xml names} {
- tdom::pullparser pp
- pp input $xml
- set result [list]
- pp next
- puts "-next [time {
- pp find-element -names $names
- while {[pp state] ne "END_DOCUMENT"} {
- lappend result [pp tag]
- pp find-element -next
- }
- }]"
- pp delete
- }
- foreach {nrNoise noiseElement nrMeat meatPrefix size} {
- 10 "elementNoise" 40 "element" 1000000
- 5 "elementNoise" 5 "element" 1000000
- 5 "elementNoise" 5 "e" 1000000
- 2 "elementNoise" 5 "element" 1000000
- 2 "elementNoise" 100 "element" 1000000
- 20 "elementNoise" 100 "element" 1000000
- 20 "earlydistinct" 100 "element" 1000000
- 100 "elementNoise" 20 "element" 1000000
- } {
- puts "$nrNoise $noiseElement $nrMeat $meatPrefix $size"
- lassign [generateInput $nrNoise $noiseElement $nrMeat $meatPrefix $size] xml names
- testnames $xml $names
- testnameshashed $xml $names
- testnameshashednext $xml $names
- puts ""
- }