Răsfoiți Sursa

Default benchmark size to 25. Add 'reduce_allocs' option

Hugh 9 ani în urmă
părinte
comite
4542ea5126
1 a modificat fișierele cu 18 adăugiri și 6 ștergeri
  1. 18 6
      tests/benchs/mandelbrot/Mandelbrot.hx

+ 18 - 6
tests/benchs/mandelbrot/Mandelbrot.hx

@@ -37,7 +37,7 @@ class Complex
 
 
 class Mandelbrot
 class Mandelbrot
 {
 {
-   static inline var SIZE = 10;
+   static inline var SIZE = 25;
    static inline var MaxIterations = 1000;
    static inline var MaxIterations = 1000;
    static inline var MaxRad = 1<<16;
    static inline var MaxRad = 1<<16;
    static inline var width = 35*SIZE;
    static inline var width = 35*SIZE;
@@ -62,14 +62,30 @@ class Mandelbrot
             trace(y);
             trace(y);
          for(x in 0...width)
          for(x in 0...width)
          {
          {
+            var iteration = 0;
+
+            #if reduce_allocs
+            var offsetI = x*scale - 2.5;
+            var offsetJ =  y*scale - 1.0;
+            var valI = 0.0;
+            var valJ = 0.0;
+            while( valI*valI+valJ*valJ<MaxRad && iteration<MaxIterations)
+            {
+               var vi = valI;
+               valI = valI*valI - valJ*valJ + offsetI;
+               valJ = 2.0*vi*valJ + offsetJ;
+               iteration++;
+            }
+            #else
             var offset = createComplex(x*scale - 2.5,y*scale - 1);
             var offset = createComplex(x*scale - 2.5,y*scale - 1);
             var val = createComplex(0.0,0.0);
             var val = createComplex(0.0,0.0);
-            var iteration = 0;
             while( complexLength2(val)<MaxRad && iteration<MaxIterations)
             while( complexLength2(val)<MaxRad && iteration<MaxIterations)
             {
             {
                val = complexAdd( complexSquare(val), offset );
                val = complexAdd( complexSquare(val), offset );
                iteration++;
                iteration++;
             }
             }
+            #end
+
             image[outPixel++] = palette[iteration];
             image[outPixel++] = palette[iteration];
          }
          }
       }
       }
@@ -95,11 +111,7 @@ class Mandelbrot
 
 
    public static function now()
    public static function now()
    {
    {
-      #if cppia
-      return 0;
-      #else
       return haxe.Timer.stamp();
       return haxe.Timer.stamp();
-      #end
    }
    }
 
 
    public static function complexLength2(val:Complex) : Float
    public static function complexLength2(val:Complex) : Float