Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
(time (f))
#include <chrono>
double measure() {
using namespace std::chrono;
const auto start{ high_resolution_clock::now() };
f();
const auto elapsed{ high_resolution_clock::now() - start };
const double seconds{ duration_cast<duration<double>>(elapsed).count() };
return seconds;
}
var s = Stopwatch()..start();
f();
s.stop();
print(s.elapsed);
integer, parameter :: i8 = selected_int_kind(15)
integer(kind=i8) :: start, finish, rate
call system_clock (count_rate=rate)
call system_clock (count=start)
call f()
call system_clock (count=finish)
print *,(finish-start)/real(rate)
function clock(f) {
var start = performance.now();
f();
var end = performance.now();
return end - start;
}
function clock(f) {
var start = new Date().getTime();
f();
var end = new Date().getTime();
return end - start;
}
long clock(Runnable f) {
long t0 = System.currentTimeMillis();
f.run();
long t1 = System.currentTimeMillis();
return t1 - t0;
}
(time (f))
$start = microtime(TRUE);
f();
$end = microtime(TRUE);
echo $end - $start, PHP_EOL;
var
Start, Duration: DWord; // replaces TDateTime
begin
Start := GetTickCount64; // better than Now
f;
Duration := GetTickCount64 - Start;
end.
def clock
t = Time.now
yield
Time.now - t
end
d = clock{ f }