oga/benchmark
Yorick Peterse 4f94d03a85 Improved NodeSet performance by a factor of 50
This change is broken up in to two parts:

1. Using a Hash to track if a node is already in a NodeSet
2. Only calling take_ownership when an owner is set

== Using a Hash

Previously various methods such as NodeSet#push and NodeSet#unshift
would call Array#include? (on the internal "nodes" Array) to see if a
node is already present in the set. This is quite problematic
performance wise, especially for large NodeSets. In fact, for the
attached benchmark the vast majority of the time was spent in
Array#include? calls.

Because a NodeSet demands ordering of nodes and must be able to access
them by index (something Set can't do without relying on Enumerable), a
Hash is used to separately keep track of what nodes are in a NodeSet.
This means that checking the presence of a node is simply a matter of
checking a Hash key's presence.

== Calling take_ownership

The if-check for the "owner" variable has been moved out of the
"take_ownership" method and into the methods that call "take_ownership".
This ensures the method isn't called in the first place if no owner is
present, at the cost of slightly more code repetition. The same applies
to the "remove_ownership" method.

== Conclusion

The combined result is a speedup of about 50x when running the attached
concurrent_time_bench.rb benchmark.
2015-08-19 01:36:37 +02:00
..
css/parser Added CSS/XPath Parser.parse_with_cache 2015-03-23 00:22:59 +01:00
fixtures Added a KAF fixture file 2015-08-18 22:32:57 +02:00
html/lexer Add HTML lexer large input timing benchmark 2015-05-23 06:54:15 +02:00
xml Added ips benchmark for NodeSet#push 2015-08-19 01:20:27 +02:00
xpath Improved NodeSet performance by a factor of 50 2015-08-19 01:36:37 +02:00
benchmark_helper.rb Fixed oga requires for benchmarking/profiling 2015-08-19 01:27:01 +02:00