render_local.c
changeset 12 43297144f196
parent 11 082bfaf38cf0
child 13 ee426f453cf5
--- a/render_local.c	Fri Jun 06 18:35:46 2008 +0300
+++ b/render_local.c	Fri Jun 06 23:37:45 2008 +0300
@@ -1,19 +1,23 @@
 #include <stdlib.h>
+#include <time.h>
 #include <assert.h>
 
 #include "common.h"
 #include "render_internal.h"
 #include "render_local.h"
 #include "render_png.h"
-#include "mandelbrot.h"
+#include "render_mandelbrot.h"
 
 int render_local (struct render *render, double *duration) {
     assert(render->mode == RENDER_PNG);
 
     unsigned char *rowbuf = NULL;
     struct render_png *png_ctx = NULL;
+    clock_t t1, t2;
 
-    *duration = -1;
+    
+    if (duration)
+        *duration = -1;
 
     // alloc the memory buffer
     if (!(rowbuf = malloc(render->img_w)))
@@ -28,9 +32,17 @@
         ERROR("render_local_mem");
    
     // then we can actually render
-    if (duration ? render_mandelbrot_timed(render, duration) : render_mandelbrot(render))
+    t1 = clock();
+
+    if (render_mandelbrot(render))
         ERROR("render_mandelbrot");
 
+    t2 = clock();
+    
+    // calculate the time taken
+    if (duration)
+        *duration = ((double)(t2 - t1))/CLOCKS_PER_SEC;
+
     // success
     return 0;