File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed
benchmarks/benchmark-others/bigarrays Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ .PHONY : bench perform
2+
3+ export NAME =Others
4+ export SUBNAME =bigarrays
5+
6+ SHELL =/bin/bash -o pipefail
7+
8+ bench :
9+ @date -u +" %FT%TZ - $( NAME) /$( SUBNAME) : starting"
10+ ocamlc bench.ml -o bench
11+ $(MAKE ) perform COMPILER=js_of_ocaml SCRIPT=bench.js KIND=js
12+ $(MAKE ) perform COMPILER=wasm_of_ocaml SCRIPT=bench.wasm.js KIND=wasm
13+ @date -u +" %FT%TZ - $( NAME) /$( SUBNAME) : done"
14+
15+ perform :
16+ $(COMPILER ) --opt 2 --pretty bench -o $(SCRIPT )
17+ /usr/bin/time -f ' {"compiler": "$(COMPILER)", "time":"%E"}' node $(SCRIPT ) 2>&1 | \
18+ sh ../../utils/format_metrics.sh exec | \
19+ sh ../../utils/aggregate.sh $(KIND )
Original file line number Diff line number Diff line change 1+ let pi = 4. *. atan 1.
2+
3+ let deltay = 40_000. /. 360. /. 3600. *. 1000.
4+
5+ let deltax = deltay *. cos (44. *. pi /. 180. )
6+
7+ let precompute tile_height tile_width tile =
8+ let normals =
9+ Bigarray. (Array3. create Int8_signed C_layout ) (tile_height - 2 ) (tile_width - 2 ) 3
10+ in
11+ let heights =
12+ Bigarray. (Array2. create Float32 C_layout ) (tile_height - 2 ) (tile_width - 2 )
13+ in
14+ for y = 1 to tile_height - 2 do
15+ for x = 1 to tile_width - 2 do
16+ let nx = (tile.{y, x - 1 } -. tile.{y, x + 1 }) *. deltay in
17+ let ny = (tile.{y - 1 , x} -. tile.{y + 1 , x}) *. deltax in
18+ let nz = 2. *. deltax *. deltay in
19+ let n = 127. /. sqrt ((nx *. nx) +. (ny *. ny) +. (nz *. nz)) in
20+ normals.{tile_height - 2 - y, x - 1 , 0 } < - truncate (nx *. n);
21+ normals.{tile_height - 2 - y, x - 1 , 1 } < - truncate (ny *. n);
22+ normals.{tile_height - 2 - y, x - 1 , 2 } < - truncate (nz *. n);
23+ heights.{tile_height - 2 - y, x - 1 } < - tile.{y, x}
24+ done
25+ done
26+
27+ let tile_height = 1024
28+
29+ let tile_width = 1024
30+
31+ let tile = Bigarray. (Array2. create Float32 C_layout ) tile_height tile_width
32+
33+ let () =
34+ for _ = 1 to 30 do
35+ precompute tile_height tile_width tile
36+ done
You can’t perform that action at this time.
0 commit comments