Var is Beyond Slow

Reporter: RobertBColton  |  Status: closed  |  Last Modified: May 06, 2019, 08:53:38 AM

@rpjohnst said it before and now it's time for me to confirm it, ENIGMA's var is unbelievably slow and we need to improve its performance. I have several graphics benchmarks that really outperform GMSv1.4 when I switch them from var to int. The simplest example I have is a benchmark that draws 5000 sprites at random locations. Just using int in place of var for the location more than doubles the framerate from 297~ fps to 687~ fps. Using variant is almost as fast as the int also and definitely faster than GMSv1.4.

Forum post by TheExDeus when he originally raised the issue:

Download Draw Sprite Benchmark:

Max FPS Var Variant float double Int
GL1 🔻 284 ✔️ 587 ✔️ 610 ✔️ 612 ✔️ 603
DX9 🔻 300 ✔️ 661 ✔️ 667 ✔️ 674 ✔️ 689
GMSv1.4 ✔️ 466 N/A N/A N/A N/A
// create event
room_speed = 99999;

// draw event
repeat (5000) {
    var xx, yy;
    xx = random(room_width);
    yy = random(room_height);
    draw_sprite(spr_0, 0, xx, yy);
room_caption = string(fps);
Last I checked room_caption was taken out after Studio 1.3 was released.

Change it to window_set_caption(string(fps));, and remove the call to set_synchronization(false); which is also deprecated. I don't draw the FPS because then it may interfere with ENIGMA or GMS's batching mechanism and skew the results

Yeah i know, i was just making an observation.

I can investigate why var has become so slow this coming weekend. I'm swamped with family stuff right now, and I have work to contend with as well. Bug me Wednesday evening; I may have time, then.

just make jdi support c++17 and we can use std::variant

The state of this issue has been improved with #1644, but we can go farther yet. As the benchmark I ran in that pull request shows, we can do more to optimize the set time of a var.

Master Pull Request
var-benchmark-master var-benchmark-pr


Closing as resolved by #1676. I reran the var benchmark and my sprite test. The sprite test is now performing as fast as variant even when using var.

Download Benchmark GMX:

Var Benchmark

Please sign in to post comments, or you can view this issue on GitHub.