Optimising collectOpenGraph(). Running a benchmark for 3 seconds. higher number of calls is better. Here is the output on my computer.
1. Initial state Higher values than 3617.11/s (n=10996) is better timethis for 3: 3 wallclock secs ( 2.94 usr + 0.10 sys = 3.04 CPU) @ 3617.11/s (n=10996)
Below is the benchmark.
2. With precompiled XPATH queries. Not much faster than hardcodded arguments
Benchmark: timing 400000 iterations of HARD_XPATH, PRECOMPILED_XPATH, RAW_XPATH...
HARD_XPATH: 20 wallclock secs (20.05 usr + 0.01 sys = 20.06 CPU) @ 19940.18/s (n=400000)
PRECOMPILED_XPATH: 19 wallclock secs (19.14 usr + 0.01 sys = 19.15 CPU) @ 20887.73/s (n=400000)
RAW_XPATH: 20 wallclock secs (20.10 usr + 0.00 sys = 20.10 CPU) @ 19900.50/s (n=400000)