new Benchmark("script_execute_ext vs function call", [
new TestCase("script_execute_ext", function(iterations) {
var _args = [spr_quack, 0, 0, 0];
repeat(iterations) {
script_execute_ext(draw_sprite, _args);
}
}),
new TestCase("function call", function(iterations) {
repeat(iterations) {
draw_sprite(spr_quack, 0, 0, 0);
}
})
]),
#script_execute_ext vs function call (draw_sprite)
1 messages · Page 1 of 1 (latest)
I've already known about this from awhile ago with the GM Community Toolbox, but I figured doing this with draw_sprite could be nice to see
For context: https://github.com/Alphish/gm-community-toolbox/issues/17#issuecomment-1622047024
i'm actually curious now
what code are you running in the script_execute_ext version?
okay that was going to be my first question
my second question was going to be how it shakes out if you use draw_sprite_general or something with a lot more arguments
Hmm
each argument to a function call is a vm stack push, which isn't much but it's something, and if you have to do like ten of them when you call the function vs just two for the args array and the function id you might find something interesting
if you have a lot of logic conditional to each draw call i would say this is maybe worth the hit
if only to keep things tidy
(i was expecting much worse tbh)
i was too
I also threw in *_ext just to see
last time i benchmarked script execute for builts i wasnt impressed
new Benchmark("script_execute_ext vs function call", [
new TestCase("script_execute_ext(draw_sprite, ...)", function(iterations) {
var _args = [spr_quack, 0, 0, 0];
repeat(iterations) {
script_execute_ext(draw_sprite, _args);
}
}),
new TestCase("draw_sprite(...)", function(iterations) {
repeat(iterations) {
draw_sprite(spr_quack, 0, 0, 0);
}
}),
new TestCase("script_execute_ext(draw_sprite_ext, ...)", function(iterations) {
var _args = [spr_quack, 0, 0, 0, 0, 0, 0, 0, 0];
repeat(iterations) {
script_execute_ext(draw_sprite_ext, _args);
}
}),
new TestCase("draw_sprite_ext(...)", function(iterations) {
repeat(iterations) {
draw_sprite_ext(spr_quack, 0, 0, 0, 0, 0, 0, 0, 0);
}
}),
new TestCase("script_execute_ext(draw_sprite_general, ...)", function(iterations) {
var _args = [spr_quack, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
repeat(iterations) {
script_execute_ext(draw_sprite_general, _args);
}
}),
new TestCase("draw_sprite_general(...)", function(iterations) {
repeat(iterations) {
draw_sprite_general(spr_quack, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}
})
]),
okay thats more or less what i was expecting
It's honestly not super bad, provided that you can keep and preallocate some kind of arguments array with all of your needed arguments
this is basically the sprite version of "not recalculating the same world matrix every draw event" in 3D
yeah
if your draw properties dont change every frame you might as well keep them around
gm has changed so much lately, with russell tinkering around the place, that this is as surprising as it is not surprising
i guess this is kind of as close to retained-mode rendering as you can get in gamemaker
tab are you in the new runtime beta?
You know I am

I've been meaning to tear apart GM Benchmark again and try to get it working in new runtime
(aka killing off Scribble)
been avoiding gm server lol
Huh
I reran the test a couple times and it seems like the results has differed slightly in YYC
This was the "first run" in YYC
#JustGameMakerThings or I suppose #JustCPUThings
haha
I wonder if it would be useful to get the variance from average additionally to just the average result
test app should probably show deviation hunh
I ve been thinking about adding it myself and pull request it for a while, but I thought maybe it wasn't all that necessary.
I mean it would be good I'd reckon haha
hmm
could probably add that without too much pain
i'll try to remember to do that some time in the next 9 years
okay now this is interesting: in a test where the content actually ends up on the screen, i found that script_execute_ext is actually slower than writing everything out the long way
consistently by about 10-15% or so
also we're using the instance variables instead of locals here because variable fetches take time too - and yet it's still slower
the real test
in yyc the delta's even bigger, because accessing variables is slightly cheaper and the script overhead is otherwise about the same
why self dot
because i said so
self dot is fun
ok
instance count ?