Added functions to easily time and profile a function.
author |
Jonatan Werpers <jonatan@werpers.com> |
date |
Tue, 24 May 2016 08:42:27 +0200 |
parents |
e8c5092d3f1b |
children |
6db427e07edd |
files |
prof.m time.m |
diffstat |
2 files changed, 20 insertions(+), 0 deletions(-)
[+]
|
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/prof.m Tue May 24 08:42:27 2016 +0200
@@ -0,0 +1,10 @@
+function prof(f)
+ profile on
+ try
+ f();
+ profile viewer
+ catch e
+ fprintf(2, '\n%s', getReport(e));
+ profile clear
+ end
+end
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/time.m Tue May 24 08:42:27 2016 +0200
@@ -0,0 +1,10 @@
+function t = time(f)
+ s = tic();
+
+ f();
+
+ if nargout == 1
+ t = toc(s);
+ else
+ toc(s);
+end
\ No newline at end of file