Perl test 1 is with no threshold filter on constraints (which means that all constraints are added, which takes much longer). For test 2, a threshold of 0.95 was used, which is the current standard for the toolkit. Python tests 3 and 4 are very similar. None of them uses a threshold. The only difference is in the method Graph._add_constraint_to_queue(): in 3 the inverted constraint is also added, in 4 it isn't. The results are the same, but 4 is faster. The Python code was not tested with the threshold.
1 Perl, no threshold 34 2 Perl, threshold of 0.95 9 3 Python, no threshold, adding inverted constraints 29 4 Python, no threshold, no inverted constraints 23
It seems fair to say that the Python implementation is 15-30% faster. What's more, the Python version derives more links: 5050 versus 3556 (perl test3). This is not yet explained.
The closure phase takes about ten times more time that the reduction phase, this may be even worse for larger documents. The optimizations suggested in the specifications stiil seem to make sense (although the gain on compiling out intersections is smaller than expected). In addition, the following things can be done (listed with the highest-impact changes first):
Test 5 includes the optimizations just mentioned, test 6 adds a threshold on confidence on classifier links. The speed improvement from test 4 to 5 is about 70%, more than bargained for (and more than reported by the profiler, which suggested a 55% improvement). Test 6 took less than a second (0.54 in fact). The speedup there is much bigger than with the Perl version probably because the Perl version seemed to miss some derivations, which must have sped up the system, skewing speed test 1. It seems fair to say that the partially optimized Python version is more than 10 times faster than the Perl version. This needs to be checked on all of TimeBank.
1 Perl, no threshold 34 2 Perl, threshold of 0.95 9 3 Python, no threshold, adding inverted constraints 29 4 Python, no threshold, no inverted constraints 23 5 Python, like 4, but with some optimizations 7 6 Python, like 5, using a threshold of 0.95 1
For the reduction phase, the first two items above were implemented as well as the use of the source attribute for deciding when an edge is derivable. This gave very good speed improvements: the CPU time reported by the profiler went down from 0.160 to 0.030 (about 80% faster).