Mercurial > repos > public > sbplib
comparison +noname/benchmark.m @ 42:f121bf58c1b9
Added a function for easily benchmarking a Discretization.
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Thu, 05 Nov 2015 16:08:57 -0800 |
| parents | |
| children | 1fe783681f9f |
comparison
equal
deleted
inserted
replaced
| 41:910a05dcdfdf | 42:f121bf58c1b9 |
|---|---|
| 1 % animate(discretization, N, time_method) | |
| 2 % | |
| 3 % Example: | |
| 4 % benchmark(discr,100) | |
| 5 % benchmark(discr,1000,'rk4') | |
| 6 | |
| 7 function hand = benchmark(discretization,N ,time_method,do_profile) | |
| 8 default_arg('N',100); | |
| 9 default_arg('time_method',[]); | |
| 10 | |
| 11 fprintf('Creating time discretization'); | |
| 12 tic | |
| 13 ts = discretization.getTimestepper(time_method); | |
| 14 fprintf(' - done %fs\n', toc()); | |
| 15 | |
| 16 if do_profile | |
| 17 profile on | |
| 18 end | |
| 19 | |
| 20 fprintf('Taking %d steps',N); | |
| 21 tic; | |
| 22 ts.stepN(N,true); | |
| 23 fprintf(' - done %fs\n', toc()); | |
| 24 | |
| 25 if do_profile | |
| 26 profile viewer | |
| 27 end | |
| 28 end |
