mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-07-24 07:30:43 +00:00
create basic terrascript performance test
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
num epsilon = 0.001;
|
||||
|
||||
for(num n = 1; n < 1000000; n = n + 1) {
|
||||
|
||||
num x = n;
|
||||
|
||||
num root = 0;
|
||||
|
||||
while(true) {
|
||||
root = 0.5 * (x + (n / x));
|
||||
|
||||
num diff = root - x;
|
||||
if(diff < 0) diff = -diff;
|
||||
|
||||
if(diff < epsilon) break;
|
||||
|
||||
x = root;
|
||||
}
|
||||
|
||||
num diff = root - sqrt(n);
|
||||
|
||||
if(diff < 0) diff = -diff;
|
||||
|
||||
assert(diff <= epsilon);
|
||||
}
|
||||
Reference in New Issue
Block a user