-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] prepare project for benchmarking, add deps and vector benchmarks
- Loading branch information
1 parent
4366b08
commit 6598437
Showing
3 changed files
with
193 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
#+SETUPFILE: ../../src/setup.org | ||
|
||
* Contents :toc_4_gh: | ||
- [[#vector-benchmarks][Vector benchmarks]] | ||
- [[#constants][Constants]] | ||
- [[#vec2][Vec2]] | ||
- [[#vec3][Vec3]] | ||
- [[#complete-namespace-definition][Complete namespace definition]] | ||
|
||
* Vector benchmarks | ||
|
||
** Constants | ||
|
||
#+BEGIN_SRC clojure :noweb-ref helpers | ||
(def A2 (vec2 1 2)) | ||
(def B2 (vec2 10 20)) | ||
(def C2 (vec2 100 200)) | ||
(def D2 (vec2 1000 2000)) | ||
|
||
(def A3 (vec3 1 2 3)) | ||
(def B3 (vec3 10 20 30)) | ||
(def C3 (vec3 100 200 300)) | ||
(def D3 (vec3 1000 2000 3000)) | ||
|
||
(def N 10.0) | ||
(def M 100.0) | ||
(def O 1000.0) | ||
#+END_SRC | ||
|
||
** Vec2 | ||
|
||
#+BEGIN_SRC clojure :noweb-ref bench | ||
(defgoal vec2-ops "vec2-ops") | ||
|
||
(defcase vec2-ops :add-v | ||
[] (g/+ A2 B2)) | ||
|
||
(defcase vec2-ops :add-vv | ||
[] (g/+ A2 B2 C2)) | ||
|
||
(defcase vec2-ops :add-n | ||
[] (g/+ A2 N)) | ||
|
||
(defcase vec2-ops :add-nn | ||
[] (g/+ A2 N M)) | ||
|
||
(defcase vec2-ops :add-s | ||
[] (g/+ A2 [N M])) | ||
|
||
(defcase vec2-ops :scale-v | ||
[] (g/* A2 B2)) | ||
|
||
(defcase vec2-ops :scale-n | ||
[] (g/* A2 N)) | ||
|
||
(defcase vec2-ops :madd | ||
[] (g/madd A2 N B2)) | ||
|
||
(defcase vec2-ops :madd-op2 | ||
[] (g/* (g/+ A2 N) B2)) | ||
|
||
(defcase vec2-ops :dot | ||
[] (g/dot A2 B2)) | ||
|
||
(defcase vec2-ops :normalize | ||
[] (g/normalize A2)) | ||
|
||
(defcase vec2-ops :mag | ||
[] (g/mag A2)) | ||
|
||
(defcase vec2-ops :mag-squared | ||
[] (g/mag-squared A2)) | ||
|
||
(defcase vec2-ops :mix | ||
[] (g/mix A2 B2 0.5)) | ||
|
||
(defcase vec2-ops :mix-bi | ||
[] (g/mix A2 B2 C2 D2 0.5 0.5)) | ||
|
||
(defcase vec2-ops :rotate | ||
[] (g/rotate A2 HALF_PI)) | ||
#+END_SRC | ||
|
||
** Vec3 | ||
|
||
#+BEGIN_SRC clojure :noweb-ref bench | ||
(defgoal vec3-ops "vec3-ops") | ||
|
||
(defcase vec3-ops :add-v | ||
[] (g/+ A3 B3)) | ||
|
||
(defcase vec3-ops :add-vv | ||
[] (g/+ A3 B3 C3)) | ||
|
||
(defcase vec3-ops :add-n | ||
[] (g/+ A3 N)) | ||
|
||
(defcase vec3-ops :add-nnn | ||
[] (g/+ A3 N M O)) | ||
|
||
(defcase vec3-ops :add-s | ||
[] (g/+ A3 [N M O])) | ||
|
||
(defcase vec3-ops :scale-v | ||
[] (g/* A3 B3)) | ||
|
||
(defcase vec3-ops :scale-n | ||
[] (g/* A3 N)) | ||
|
||
(defcase vec3-ops :madd | ||
[] (g/madd A3 N B3)) | ||
|
||
(defcase vec3-ops :madd-op2 | ||
[] (g/* (g/+ A3 N) B3)) | ||
|
||
(defcase vec3-ops :dot | ||
[] (g/dot A3 B3)) | ||
|
||
(defcase vec3-ops :cross | ||
[] (g/cross A3 B3)) | ||
|
||
(defcase vec3-ops :ortho-normal | ||
[] (gu/ortho-normal A3 B3 C3)) | ||
|
||
(defcase vec3-ops :normalize | ||
[] (g/normalize A3)) | ||
|
||
(defcase vec3-ops :mag | ||
[] (g/mag A3)) | ||
|
||
(defcase vec3-ops :mag-squared | ||
[] (g/mag-squared A3)) | ||
|
||
(defcase vec3-ops :mix | ||
[] (g/mix A3 B3 0.5)) | ||
|
||
(defcase vec3-ops :mix-bi | ||
[] (g/mix A3 B3 C3 D3 0.5 0.5)) | ||
|
||
(defcase vec3-ops :rotate-x | ||
[] (g/rotate-x A3 HALF_PI)) | ||
|
||
(defcase vec3-ops :rotate-axis | ||
[] (g/rotate-around-axis A3 v/V3Y HALF_PI)) | ||
#+END_SRC | ||
|
||
** Complete namespace definition | ||
|
||
#+BEGIN_SRC clojure :tangle ../babel/benchmarks/thi/ng/geom/bench/core/vector.clj :noweb yes :mkdirp yes :padline no | ||
(ns thi.ng.geom.bench.core.vector | ||
(:require | ||
[perforate.core :refer :all] | ||
[thi.ng.geom.core :as g] | ||
[thi.ng.geom.core.utils :as gu] | ||
[thi.ng.geom.core.vector :as v :refer [vec2 vec3]] | ||
[thi.ng.common.math.core :as m :refer [*eps* HALF_PI PI]])) | ||
|
||
<<helpers>> | ||
|
||
<<bench>> | ||
#+END_SRC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters