[pypy-commit] extradoc extradoc: converted to benchmark
hakanardo
noreply at buildbot.pypy.org
Sat Jun 11 14:32:48 CEST 2011
Author: Hakan Ardo <hakan at debian.org>
Branch: extradoc
Changeset: r3642:b2156f85653b
Date: 2011-06-11 14:34 +0200
http://bitbucket.org/pypy/extradoc/changeset/b2156f85653b/
Log: converted to benchmark
diff --git a/talk/iwtc11/benchmarks/benchmark.sh b/talk/iwtc11/benchmarks/benchmark.sh
--- a/talk/iwtc11/benchmarks/benchmark.sh
+++ b/talk/iwtc11/benchmarks/benchmark.sh
@@ -15,6 +15,7 @@
$* convolution/conv3x3.cc -lstdc++; /usr/bin/time -f %e ./a.out 1000000 3 > /dev/null
$* convolution/conv3x3.cc -lstdc++; /usr/bin/time -f %e ./a.out 1000 1000 > /dev/null
$* convolution/dilate3x3.cc -lstdc++; /usr/bin/time -f %e ./a.out 1000 1000 > /dev/null
+ $* image/sobel.cc -lstdc++; /usr/bin/time -f %e ./a.out 1002 1002 > /dev/null
rm a.out
else
$* sqrt/time_sqrt.py float
@@ -26,4 +27,5 @@
$* convolution/time_conv2d.py
$* image/noborder.py NoBorderImagePadded
$* image/noborder.py NoBorderImage
+ $* image/time_sobel.py NoBorderImagePadded
fi
diff --git a/talk/iwtc11/benchmarks/image/sobel.cc b/talk/iwtc11/benchmarks/image/sobel.cc
new file mode 100644
--- /dev/null
+++ b/talk/iwtc11/benchmarks/image/sobel.cc
@@ -0,0 +1,51 @@
+// A safe array example.
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+class Array2D {
+ double *data;
+public:
+ int width, height;
+ Array2D(int w, int h) {
+ width = w;
+ height = h;
+ data = (double *) malloc(w*h*sizeof(double));
+ }
+ double &operator()(int x, int y) {
+ if (x >= 0 && x < width && y >= 0 && y < height) {
+ return data[y*width + x];
+ }
+ printf("IndexError\n");
+ exit(1);
+ }
+};
+
+void sobel_magnitude(Array2D &a, Array2D &b) {
+ int x, y;
+ for (y=1; y<a.height-1; y++) {
+ for (x=1; x<a.width-1; x++) {
+ double dx = -1.0*a(x-1, y-1) + 1.0*a(x+1, y-1) +
+ -2.0*a(x-1, y) + 2.0*a(x+1, y) +
+ -1.0*a(x-1, y+1) + 1.0*a(x+1, y+1);
+
+ double dy = -1.0*a(x-1, y-1) - 2.0*a(x, y-1) - 1.0*a(x+1, y-1) +
+ 1.0*a(x-1, y+1) + 2.0*a(x, y+1) + 1.0*a(x+1, y+1);
+ b(x, y) = sqrt(dx*dx + dy*dy) / 4.0;
+
+ }
+ }
+}
+
+int main(int ac, char **av) {
+ int w = atoi(av[1]), h = atoi(av[2]);
+ int i;
+
+ for (i=0; i<10; i++) {
+ Array2D a(w, h), b(w, h);
+ sobel_magnitude(a, b);
+ printf("%f\n", b(1,1));
+ }
+ fprintf(stderr, "sobel_magnitude: ", h);
+ return 0;
+}
diff --git a/talk/iwtc11/benchmarks/image/sobel.py b/talk/iwtc11/benchmarks/image/sobel.py
--- a/talk/iwtc11/benchmarks/image/sobel.py
+++ b/talk/iwtc11/benchmarks/image/sobel.py
@@ -23,8 +23,8 @@
-2.0 * img[p + (-1, 0)] + 2.0 * img[p + (1, 0)] + \
-1.0 * img[p + (-1, 1)] + 1.0 * img[p + (1, 1)]
dy = -1.0*img[p + (-1,-1)] -2.0*img[p + (0,-1)] -1.0*img[p + (1,-1)] + \
- 1.0*img[p + (-1, 1)] +2.0*img[p + (0, 1)] +2.0*img[p + (1, 1)]
- res[p] = sqrt(dx**2 + dy**2) / 4.0
+ 1.0*img[p + (-1, 1)] +2.0*img[p + (0, 1)] +1.0*img[p + (1, 1)]
+ res[p] = sqrt(dx*dx + dy*dy) / 4.0
return res
def uint8(img):
@@ -43,6 +43,7 @@
else:
fn = 'test.avi'
+ sys.setcheckinterval(2**30)
try:
import pypyjit
pypyjit.set_param(trace_limit=200000)
diff --git a/talk/iwtc11/benchmarks/image/time_sobel.py b/talk/iwtc11/benchmarks/image/time_sobel.py
new file mode 100644
--- /dev/null
+++ b/talk/iwtc11/benchmarks/image/time_sobel.py
@@ -0,0 +1,22 @@
+from noborder import NoBorderImagePadded, NoBorderImage
+from sobel import sobel_magnitude
+from time import time
+import sys
+
+sys.setcheckinterval(2**30)
+try:
+ import pypyjit
+ pypyjit.set_param(trace_limit=200000)
+except ImportError:
+ pass
+
+Image = eval(sys.argv[1])
+n = 1000
+
+sobel_magnitude(Image(n, n))
+
+a = time()
+for i in range(10):
+ sobel_magnitude(Image(n, n))
+b = time()
+print 'sobel(%s):' % Image.__name__, b - a
diff --git a/talk/iwtc11/benchmarks/result.txt b/talk/iwtc11/benchmarks/result.txt
--- a/talk/iwtc11/benchmarks/result.txt
+++ b/talk/iwtc11/benchmarks/result.txt
@@ -1,82 +1,86 @@
pypy
-sqrt(float): 1.20330905914
- sqrt(int): 2.41903185844
-sqrt(Fix16): 6.13185501099
-conv3(1e8): 2.07355308533
-conv5(1e8): 4.32232785225
-conv3(1e6): 0.84544801712
-conv5(1e6): 1.06041717529
-conv3(1e5): 0.779824018478
-conv5(1e5): 0.977579116821
-conv3x3(3): 0.659806966782
-conv3x3(1000): 0.754494905472
-dilate3x3(1000): 4.82968187332
-NoBorderImagePadded: 2.30471801758
-NoBorderImagePadded(iter): 0.506963014603
-NoBorderImagePadded(range): 0.498332977295
-NoBorderImage: 2.81514596939
-NoBorderImage(iter): 2.08273696899
-NoBorderImage(range): 1.95225405693
+sqrt(float): 1.20290899277
+ sqrt(int): 2.41840982437
+sqrt(Fix16): 6.10620713234
+conv3(1e8): 2.5192759037
+conv5(1e8): 2.89429306984
+conv3(1e6): 0.828789949417
+conv5(1e6): 1.01669406891
+conv3(1e5): 0.777491092682
+conv5(1e5): 0.971807956696
+conv3x3(3): 0.653658866882
+conv3x3(1000): 0.748742103577
+dilate3x3(1000): 4.8826611042
+NoBorderImagePadded: 2.31043601036
+NoBorderImagePadded(iter): 0.572638988495
+NoBorderImagePadded(range): 0.494098186493
+NoBorderImage: 2.90333104134
+NoBorderImage(iter): 2.06943392754
+NoBorderImage(range): 1.99161696434
+sobel(NoBorderImagePadded): 0.668392896652
pypy --jit enable_opts=intbounds:rewrite:virtualize:heap:unroll
-sqrt(float): 1.20050120354
- sqrt(int): 2.42964291573
-sqrt(Fix16): 6.13428783417
-conv3(1e8): 2.08279705048
-conv5(1e8): 2.34173488617
-conv3(1e6): 0.836614131927
-conv5(1e6): 1.040391922
-conv3(1e5): 0.779335021973
-conv5(1e5): 0.985204935074
-conv3x3(3): 0.675951004028
-conv3x3(1000): 0.778173923492
-dilate3x3(1000): 4.75176811218
-NoBorderImagePadded: 2.31103396416
-NoBorderImagePadded(iter): 0.506816864014
-NoBorderImagePadded(range): 0.496361970901
-NoBorderImage: 2.92268490791
-NoBorderImage(iter): 2.04088401794
-NoBorderImage(range): 1.93559288979
+sqrt(float): 1.19338798523
+ sqrt(int): 2.42711806297
+sqrt(Fix16): 6.12403416634
+conv3(1e8): 2.06937193871
+conv5(1e8): 2.26879811287
+conv3(1e6): 0.837247848511
+conv5(1e6): 1.02573990822
+conv3(1e5): 0.779927015305
+conv5(1e5): 0.975258827209
+conv3x3(3): 0.663229942322
+conv3x3(1000): 0.763913154602
+dilate3x3(1000): 4.80735611916
+NoBorderImagePadded: 2.33380198479
+NoBorderImagePadded(iter): 0.504709005356
+NoBorderImagePadded(range): 0.503198862076
+NoBorderImage: 2.93766593933
+NoBorderImage(iter): 2.04195189476
+NoBorderImage(range): 2.02779984474
+sobel(NoBorderImagePadded): 0.670017004013
pypy --jit enable_opts=intbounds:rewrite:virtualize:heap
-sqrt(float): 1.67590689659
- sqrt(int): 3.06944203377
-sqrt(Fix16): 10.3943400383
-conv3(1e8): 2.97594094276
-conv5(1e8): 3.1732480526
-conv3(1e6): 1.7523651123
-conv5(1e6): 1.92802405357
-conv3(1e5): 1.72453904152
-conv5(1e5): 1.93651390076
-conv3x3(3): 1.10019302368
-conv3x3(1000): 1.02145695686
-dilate3x3(1000): 5.10945105553
-NoBorderImagePadded: 2.4370200634
-NoBorderImagePadded(iter): 1.55626583099
-NoBorderImagePadded(range): 1.5247399807
-NoBorderImage: 2.7648730278
-NoBorderImage(iter): 1.90325784683
-NoBorderImage(range): 2.04479312897
+sqrt(float): 1.69957995415
+ sqrt(int): 3.13235807419
+sqrt(Fix16): 10.325592041
+conv3(1e8): 2.997631073
+conv5(1e8): 3.13820099831
+conv3(1e6): 1.7843170166
+conv5(1e6): 1.94643998146
+conv3(1e5): 1.75876712799
+conv5(1e5): 1.96709895134
+conv3x3(3): 1.09958791733
+conv3x3(1000): 1.02993702888
+dilate3x3(1000): 5.22873902321
+NoBorderImagePadded: 2.45174002647
+NoBorderImagePadded(iter): 1.60747289658
+NoBorderImagePadded(range): 1.55282211304
+NoBorderImage: 2.91020989418
+NoBorderImage(iter): 1.97922706604
+NoBorderImage(range): 2.14161992073
+sobel(NoBorderImagePadded): 1.47591900826
gcc
-sqrt(float): 1.42
-sqrt(int): 1.92
-sqrt(Fix16): 2.03
-conv3(1e8): 2.00
-conv5(1e8): 2.42
-conv3(1e6): 1.65
-conv5(1e6): 2.04
-conv3(1e5): 1.63
-conv5(1e5): 2.01
-conv3x3(3): 1.85
-conv3x3(1000): 1.77
+sqrt(float): 1.43
+sqrt(int): 1.93
+sqrt(Fix16): 2.04
+conv3(1e8): 2.03
+conv5(1e8): 2.39
+conv3(1e6): 1.66
+conv5(1e6): 2.03
+conv3(1e5): 1.60
+conv5(1e5): 2.02
+conv3x3(3): 1.81
+conv3x3(1000): 1.79
dilate3x3(1000): 3.26
+sobel_magnitude: 1.37
gcc -O2
sqrt(float): 1.15
sqrt(int): 1.86
-sqrt(Fix16): 1.90
+sqrt(Fix16): 1.89
conv3(1e8): 1.22
conv5(1e8): 1.37
conv3(1e6): 1.00
@@ -86,18 +90,20 @@
conv3x3(3): 0.25
conv3x3(1000): 0.23
dilate3x3(1000): 0.27
+sobel_magnitude: 0.25
gcc -O3 -march=native
-sqrt(float): 1.14
+sqrt(float): 1.15
sqrt(int): 1.82
sqrt(Fix16): 1.89
-conv3(1e8): 1.13
-conv5(1e8): 1.15
-conv3(1e6): 0.97
-conv5(1e6): 0.96
+conv3(1e8): 1.12
+conv5(1e8): 1.16
+conv3(1e6): 0.96
+conv5(1e6): 0.97
conv3(1e5): 0.66
-conv5(1e5): 0.76
+conv5(1e5): 0.75
conv3x3(3): 0.23
conv3x3(1000): 0.21
-dilate3x3(1000): 0.27
+dilate3x3(1000): 0.26
+sobel_magnitude: 0.25
More information about the pypy-commit
mailing list