Take the 2-minute tour ×  It often happens that I'd like to know
which of two or more alternative expressions (that should
evaluate to the same value) is fastest. For example, below are
three ways to define a function:  fooVersion1[x_]/; x > 0 :=
E^(-1/x); fooVersion1[x_] := 0;  fooVersion2[x_] := If[x > 0,
E^(-1/x), 0];  fooVersion3 = Function[x, If[x > 0, E^(-1/x),
0]];  (Granted, strictly speaking, these three versions are not
completely equivalent, but at least, for all real scalars x,
fooVersion1[x], fooVersion2[x], and fooVersion3[x] should
evaluate to the same value.)  Is there a way to determine which
one is fastest that is both simple and reasonably reliable?
share|improve this question @rm-rf Not sure about the dupe.
Benchmarking and profiling are certainly very related, yet I
would hesitate to call them the same thing. Benchmarking is
usually a process of comparing several different solutions in
terms of speed, while profiling is more about distribution of
running time for a single function over i