feat: add benchmark settings panel
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 1m59s

This commit is contained in:
2024-05-01 23:05:04 +02:00
parent 8bf2958e1d
commit d9afec5bf6
39 changed files with 1253 additions and 741 deletions

View File

@ -102,3 +102,47 @@ function decode_recursive(dense: number[] | Int32Array, index = 0) {
export function decodeNestedArray(dense: number[] | Int32Array) {
return decode_recursive(dense, 0)[0];
}
export function splitNestedArray(input: Int32Array) {
let index = 0;
const length = input.length;
let res: Int32Array[] = [];
let nextBracketIndex = 0;
let argStartIndex = 0;
let depth = -1;
while (index < length) {
const value = input[index];
if (index === nextBracketIndex) {
nextBracketIndex = index + input[index + 1] + 1;
if (value === 0) {
depth++;
} else {
depth--;
}
if (depth === 1 && value === 0) {
// if opening bracket
argStartIndex = index + 2;
}
if (depth === 0 && value === 1) {
// if closing bracket
res.push(input.slice(argStartIndex, index));
argStartIndex = index + 2;
}
index = nextBracketIndex;
continue;
}
// we should not be here
index++;
}
return res;
}

View File

@ -11,12 +11,52 @@ pub struct PathDataMut<'a> {
pub points: &'a mut [f32],
}
impl PathDataMut<'_> {
pub fn get_length(&self) -> f32 {
let mut l = 0.0;
for i in 0..(self.length - 1) {
let a = vec3(
self.points[i * 4],
self.points[i * 4 + 1],
self.points[i * 4 + 2],
);
let b = vec3(
self.points[(i + 1) * 4],
self.points[(i + 1) * 4 + 1],
self.points[(i + 1) * 4 + 2],
);
l += (b - a).length();
}
l
}
}
pub struct PathData<'a> {
pub depth: i32,
pub length: usize,
pub points: &'a [f32],
}
impl PathData<'_> {
pub fn get_length(&self) -> f32 {
let mut l = 0.0;
for i in 0..(self.length - 1) {
let a = vec3(
self.points[i * 4],
self.points[i * 4 + 1],
self.points[i * 4 + 2],
);
let b = vec3(
self.points[(i + 1) * 4],
self.points[(i + 1) * 4 + 1],
self.points[(i + 1) * 4 + 2],
);
l += (b - a).length();
}
l
}
}
pub fn create_multiple_paths(amount: usize, point_amount: usize, depth: i32) -> Vec<i32> {
let output_size = amount * (point_amount * 4 + PATH_HEADER_SIZE + 4) + 4;

View File

@ -162,7 +162,12 @@ pub fn evaluate_vec3(input_args: &[i32]) -> Vec<f32> {
}
pub fn evaluate_float(arg: &[i32]) -> f32 {
decode_float(evaluate_int(arg))
let res = decode_float(evaluate_int(arg));
if res.is_nan() {
0.0
} else {
res
}
}
pub fn evaluate_int(input_args: &[i32]) -> i32 {