Skip to content

Commit e7058a8

Browse files
committed
add more benchmarks
1 parent 2cfd7ad commit e7058a8

File tree

7 files changed

+57
-1
lines changed

7 files changed

+57
-1
lines changed

assets/benchmarks/function/call.lua

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function bench()
2+
noop()
3+
end

assets/benchmarks/function/call.rhai

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn bench(){
2+
noop.call();
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function bench()
2+
noop_4_args(1,"asd",{1,2,3}, {asd = 1})
3+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn bench(){
2+
noop_4_args.call(1,"asd",[1,2,3],#{ asd: 1});
3+
}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
reseed()
3+
4+
local matrix = nil
5+
local vector = nil
6+
function pre_bench()
7+
-- generate random 3x3 matrix and 3x1 vec
8+
vector = Vec3.new(random(1,999), random(1,999), random(1,999))
9+
matrix = Mat3.from_cols(
10+
Vec3.new(random(1,999), random(1,999), random(1,999)),
11+
Vec3.new(random(1,999), random(1,999), random(1,999)),
12+
Vec3.new(random(1,999), random(1,999), random(1,999))
13+
)
14+
end
15+
16+
function bench()
17+
local mul = matrix * vector
18+
local add = matrix + vector
19+
local div = vector / matrix
20+
end
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
reseed.call();
3+
4+
let matrix = ();
5+
let vector = ();
6+
fn pre_bench(){
7+
vector = Vec3.new_.call(random.call(1,999), random.call(1,999), random.call(1,999));
8+
matrix = Mat3.from_cols.call(
9+
Vec3.new_.call(random.call(1,999), random.call(1,999), random.call(1,999)),
10+
Vec3.new_.call(random.call(1,999), random.call(1,999), random.call(1,999)),
11+
Vec3.new_.call(random.call(1,999), random.call(1,999), random.call(1,999))
12+
);
13+
}
14+
15+
fn bench() {
16+
let mul = matrix * vector;
17+
let add = matrix + vector;
18+
let div = vector / matrix;
19+
}

crates/testing_crates/script_integration_test_harness/src/test_functions.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use bevy_mod_scripting_core::{
1818
},
1919
pretty_print::DisplayWithWorld,
2020
ReflectReference, ScriptComponentRegistration, ScriptResourceRegistration,
21-
ScriptTypeRegistration,
21+
ScriptTypeRegistration, ScriptValue,
2222
},
2323
error::InteropError,
2424
};
@@ -137,6 +137,11 @@ pub fn register_test_functions(world: &mut App) {
137137
*rng = ChaCha12Rng::from_seed(seed);
138138
})
139139
.register("make_hashmap", |map: HashMap<String, usize>| map)
140+
.register("noop", || {})
141+
.register(
142+
"noop_4_args",
143+
|_a: ScriptValue, _b: ScriptValue, _c: ScriptValue, _d: ScriptValue| {},
144+
)
140145
.register(
141146
"assert_str_eq",
142147
|s1: String, s2: String, reason: Option<String>| {

0 commit comments

Comments
 (0)