Comparing efficiency of two algorithms