soulcutter / saxerator

A SAX-based XML parser for parsing large files into manageable chunks
MIT License
128 stars 19 forks source link

Performance update part 1 #44

Closed fanantoxa closed 8 years ago

fanantoxa commented 8 years ago

I've finished fir performance update. Benchmarks from master:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Benchmark with :nokogiri parser

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

       user     system      total        real
for_tag  8.020000   0.010000   8.030000 (  8.032753)
at_depth  6.150000   0.000000   6.150000 (  6.147006)
within  7.890000   0.020000   7.910000 (  7.912147)
composite  5.480000   0.130000   5.610000 (  5.609364)

##########################################################

for_tag:   100000 artist elements parsed
at_depth:  400000 elements parsed
within:    100000 artists children parsed
composite: 0 names within artist nested 3 tags deep parsed

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Benchmark with :ox parser

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

       user     system      total        real
for_tag  5.390000   0.110000   5.500000 (  5.512138)
at_depth  3.830000   0.070000   3.900000 (  3.899632)
within  5.210000   0.130000   5.340000 (  5.345308)
composite  3.030000   0.080000   3.110000 (  3.117383)

##########################################################

for_tag:   100000 artist elements parsed
at_depth:  400000 elements parsed
within:    100000 artists children parsed
composite: 0 names within artist nested 3 tags deep parsed

Benchmarks with changes on this PR:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Benchmark with :nokogiri parser

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

       user     system      total        real
for_tag  7.730000   0.020000   7.750000 (  7.750011)
at_depth  5.950000   0.010000   5.960000 (  5.950748)
within  7.450000   0.010000   7.460000 (  7.456025)
composite  5.480000   0.000000   5.480000 (  5.489144)

##########################################################

for_tag:   100000 artist elements parsed
at_depth:  400000 elements parsed
within:    100000 artists children parsed
composite: 0 names within artist nested 3 tags deep parsed

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Benchmark with :ox parser

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

       user     system      total        real
for_tag  5.020000   0.010000   5.030000 (  5.031486)
at_depth  3.580000   0.010000   3.590000 (  3.583538)
within  4.930000   0.010000   4.940000 (  4.940562)
composite  3.040000   0.000000   3.040000 (  3.046136)

##########################################################

for_tag:   100000 artist elements parsed
at_depth:  400000 elements parsed
within:    100000 artists children parsed
composite: 0 names within artist nested 3 tags deep parsed

@soulcutter I've got some performance increase, but I'm not sure that my environment was good enough prepared for benchmark. Please checn it on you PC. And if works faster - please merge it.

fanantoxa commented 8 years ago

@soulcutter Updated code with your additions. Please check.

soulcutter commented 8 years ago

Looks good to me.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Benchmark with :nokogiri parser
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
       user     system      total        real
for_tag  6.100000   0.040000   6.140000 (  6.162233)
at_depth  4.830000   0.030000   4.860000 (  4.868037)
within  6.180000   0.040000   6.220000 (  6.222976)
composite  4.660000   0.020000   4.680000 (  4.698063)
##########################################################
for_tag:   100000 artist elements parsed
at_depth:  400000 elements parsed
within:    100000 artists children parsed
composite: 0 names within artist nested 3 tags deep parsed
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Benchmark with :ox parser
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
       user     system      total        real
for_tag  4.000000   0.030000   4.030000 (  4.035326)
at_depth  2.940000   0.020000   2.960000 (  2.961429)
within  3.920000   0.020000   3.940000 (  3.951661)
composite  2.330000   0.020000   2.350000 (  2.352623)
##########################################################
for_tag:   100000 artist elements parsed
at_depth:  400000 elements parsed
within:    100000 artists children parsed
composite: 0 names within artist nested 3 tags deep parsed