aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-11-05 14:21:25 -0700
committerAlon Zakai <alonzakai@gmail.com>2011-11-05 14:21:25 -0700
commit5c5894d842b86294485bbee7079439b998aa5344 (patch)
treed5828075eb2652ab675c8a41f06cf84bf415316e
parent80d618d0452420b9c3f5a67fccbb94ba1e70785e (diff)
fix raytrace test and benchmark
-rw-r--r--tests/raytrace.cpp13
-rw-r--r--tests/raytrace.ppm17
-rw-r--r--tests/raytrace_7_256.ppm259
-rw-r--r--tests/runner.py4
4 files changed, 280 insertions, 13 deletions
diff --git a/tests/raytrace.cpp b/tests/raytrace.cpp
index 317e0f42..08209a00 100644
--- a/tests/raytrace.cpp
+++ b/tests/raytrace.cpp
@@ -9,8 +9,6 @@
//#include "emscripten.h"
-static int outputLeft = 550; // limit output, so we do not benchmark speed of printing
-
#define GIMME_SHADOWS // usage: ./sphereflake [lvl=6] >pix.ppm
enum { childs = 9, ss= 2, ss_sqr = ss*ss }; /* not really tweakable anymore */
@@ -114,24 +112,19 @@ static void trace_rgss(const int width,const int height) {
}
v_t scan(0,w-1,std::max(w,h)); /*scan line*/
for(int i=height;i;--i) {
+ int lineMean = 0;
for(int j=width;j;--j) {
double g=0;
for(int idx=0;idx < ss_sqr;++idx){ /*AA*/
ray.d=(scan+rgss[idx]).norm();
g+=ray_trace(pool,ray); /*trace*/
}
- if (outputLeft) {
- printf("%d ", int(scale*g)); // std::cout << int(scale*g)<< " ";
- outputLeft--;
- }
+ lineMean += int(scale*g);
scan.x+=1; /*next pixel*/
}
+ printf("%d : %d\n", i, lineMean/width);
scan.x=0;scan.y-=1; /*next line*/
}
- if (outputLeft) {
- printf("\n"); // std::cout << "\n"; // XXX Emscripten: std::endl crashes...
- outputLeft--;
- }
}
struct basis_t{ /* bogus and compact, exactly what we need */
diff --git a/tests/raytrace.ppm b/tests/raytrace.ppm
index 8d81573f..fe80d64e 100644
--- a/tests/raytrace.ppm
+++ b/tests/raytrace.ppm
@@ -1,4 +1,19 @@
P2
16 16
16
-0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 42 62 74 123 0 0 0 0 0 0 0 0 0 0 0 35 97 101 84 161 111 0 0 0 0 0 0 0 0 0 62 80 215 174 198 224 237 125 0 27 103 18 0 0 0 0 53 50 152 168 142 192 247 251 118 105 202 121 0 0 0 0 0 0 9 119 143 213 231 239 119 60 54 59 62 0 0 71 111 27 22 141 159 187 206 214 154 98 35 16 0 0 40 134 188 25 0 81 124 152 171 177 120 60 28 0 0 0 0 76 38 61 47 75 154 119 152 121 61 79 142 0 0 0 0 47 0 45 0 124 201 150 133 27 33 138 175 29 0 0 0 0 0 0 62 86 85 148 109 32 83 85 73 0 0 0 0 0 0 0 76 21 32 121 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+16 : 0
+15 : 0
+14 : 18
+13 : 36
+12 : 91
+11 : 112
+10 : 81
+9 : 90
+8 : 81
+7 : 70
+6 : 68
+5 : 47
+4 : 15
+3 : 3
+2 : 0
+1 : 0
diff --git a/tests/raytrace_7_256.ppm b/tests/raytrace_7_256.ppm
new file mode 100644
index 00000000..c0545167
--- /dev/null
+++ b/tests/raytrace_7_256.ppm
@@ -0,0 +1,259 @@
+P2
+256 256
+256
+256 : 0
+255 : 0
+254 : 0
+253 : 0
+252 : 0
+251 : 0
+250 : 0
+249 : 0
+248 : 0
+247 : 0
+246 : 0
+245 : 0
+244 : 0
+243 : 0
+242 : 0
+241 : 0
+240 : 0
+239 : 0
+238 : 0
+237 : 0
+236 : 0
+235 : 0
+234 : 0
+233 : 0
+232 : 0
+231 : 0
+230 : 0
+229 : 0
+228 : 0
+227 : 0
+226 : 0
+225 : 0
+224 : 0
+223 : 0
+222 : 0
+221 : 0
+220 : 1
+219 : 2
+218 : 6
+217 : 6
+216 : 5
+215 : 4
+214 : 4
+213 : 6
+212 : 10
+211 : 15
+210 : 11
+209 : 8
+208 : 12
+207 : 11
+206 : 15
+205 : 21
+204 : 20
+203 : 28
+202 : 34
+201 : 35
+200 : 31
+199 : 26
+198 : 25
+197 : 24
+196 : 21
+195 : 17
+194 : 14
+193 : 16
+192 : 18
+191 : 18
+190 : 19
+189 : 26
+188 : 38
+187 : 50
+186 : 60
+185 : 63
+184 : 67
+183 : 71
+182 : 75
+181 : 78
+180 : 83
+179 : 91
+178 : 95
+177 : 100
+176 : 103
+175 : 98
+174 : 92
+173 : 96
+172 : 101
+171 : 106
+170 : 112
+169 : 114
+168 : 115
+167 : 107
+166 : 104
+165 : 102
+164 : 99
+163 : 97
+162 : 100
+161 : 98
+160 : 93
+159 : 88
+158 : 84
+157 : 87
+156 : 88
+155 : 87
+154 : 86
+153 : 84
+152 : 79
+151 : 76
+150 : 75
+149 : 75
+148 : 68
+147 : 65
+146 : 68
+145 : 68
+144 : 68
+143 : 70
+142 : 67
+141 : 69
+140 : 70
+139 : 69
+138 : 69
+137 : 68
+136 : 69
+135 : 66
+134 : 67
+133 : 69
+132 : 73
+131 : 75
+130 : 68
+129 : 64
+128 : 66
+127 : 68
+126 : 80
+125 : 86
+124 : 85
+123 : 83
+122 : 89
+121 : 87
+120 : 85
+119 : 83
+118 : 84
+117 : 83
+116 : 78
+115 : 74
+114 : 72
+113 : 69
+112 : 70
+111 : 65
+110 : 57
+109 : 62
+108 : 67
+107 : 66
+106 : 63
+105 : 63
+104 : 61
+103 : 59
+102 : 58
+101 : 55
+100 : 61
+99 : 58
+98 : 49
+97 : 50
+96 : 51
+95 : 50
+94 : 51
+93 : 58
+92 : 65
+91 : 74
+90 : 76
+89 : 75
+88 : 72
+87 : 69
+86 : 64
+85 : 63
+84 : 57
+83 : 56
+82 : 49
+81 : 45
+80 : 47
+79 : 45
+78 : 46
+77 : 41
+76 : 43
+75 : 45
+74 : 53
+73 : 58
+72 : 57
+71 : 57
+70 : 56
+69 : 54
+68 : 49
+67 : 45
+66 : 45
+65 : 40
+64 : 35
+63 : 34
+62 : 30
+61 : 31
+60 : 34
+59 : 30
+58 : 28
+57 : 25
+56 : 21
+55 : 21
+54 : 20
+53 : 24
+52 : 23
+51 : 24
+50 : 24
+49 : 23
+48 : 15
+47 : 17
+46 : 19
+45 : 16
+44 : 13
+43 : 14
+42 : 12
+41 : 9
+40 : 9
+39 : 10
+38 : 12
+37 : 14
+36 : 11
+35 : 9
+34 : 8
+33 : 7
+32 : 7
+31 : 4
+30 : 2
+29 : 4
+28 : 3
+27 : 2
+26 : 2
+25 : 0
+24 : 0
+23 : 0
+22 : 0
+21 : 0
+20 : 0
+19 : 0
+18 : 0
+17 : 0
+16 : 0
+15 : 0
+14 : 0
+13 : 0
+12 : 0
+11 : 0
+10 : 0
+9 : 0
+8 : 0
+7 : 0
+6 : 0
+5 : 0
+4 : 0
+3 : 0
+2 : 0
+1 : 0
diff --git a/tests/runner.py b/tests/runner.py
index e31b1455..6e713fbe 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -4225,7 +4225,7 @@ TT = %s
del T # T is just a shape for the specific subclasses, we don't test it itself
- class OtherTests(RunnerCore):
+ class Other(RunnerCore):
def test_eliminator(self):
input = open(path_from_root('tools', 'eliminator', 'eliminator-test.js')).read()
expected = open(path_from_root('tools', 'eliminator', 'eliminator-test-output.js')).read()
@@ -4450,7 +4450,7 @@ else:
global POST_OPTIMIZATIONS; POST_OPTIMIZATIONS = ['closure']
src = open(path_from_root('tests', 'raytrace.cpp'), 'r').read().replace('double', 'float') # benchmark with floats
- self.do_benchmark(src, ['7', '256'], '256 256', llvm_opts=True, handpicked=False)
+ self.do_benchmark(src, ['7', '256'], open(path_from_root('tests', 'raytrace_7_256.ppm')).read(), llvm_opts=True, handpicked=True)
def test_dlmalloc(self):
global POST_OPTIMIZATIONS; POST_OPTIMIZATIONS = ['eliminator']