2 #include "pbd/compose.h"
3 #include "canvas/types.h"
4 #include "canvas/canvas.h"
8 using namespace ArdourCanvas;
13 return ((double) rand() / RAND_MAX);
17 rect_random (double rough_size)
19 double const x = double_random () * rough_size / 2;
20 double const y = double_random () * rough_size / 2;
21 double const w = double_random () * rough_size / 2;
22 double const h = double_random () * rough_size / 2;
23 return Rect (x, y, x + w, y + h);
26 Benchmark::Benchmark (string const & session)
29 string path = string_compose ("../../libs/canvas/benchmark/sessions/%1.xml", session);
30 _canvas = new ImageCanvas (new XMLTree (path), Duple (4096, 4096));
34 Benchmark::set_iterations (int n)
39 /** @return wallclock time in seconds */
44 gettimeofday (&start, 0);
46 for (int i = 0; i < _iterations; ++i) {
51 gettimeofday (&stop, 0);
55 int sec = stop.tv_sec - start.tv_sec;
56 int usec = stop.tv_usec - start.tv_usec;
62 return sec + ((double) usec / 1e6);