Add profiling test cases.
Improve performance of recursion detection.