Poor performance (single figure FPS) when using two dimensional array of structure
-
Hi there
I have been looking a creating a text mode console using a two dimensional array eg:
struct txtCell int ascii // ASCII code of character 0 - 255 int flag // If true draw cell otherwise skip (not using this ATM - I draw all cells) vector fcol // Foreground colour vector bcol // Background colour int x // Pre-calculated Screen pixel X position int y // Pre-calculated Screen pixel Y position endStruct txtCell txtScreen[80][30]
The array is scanned and each cell is drawn to the screen using an image, it all works fine but the performance (FPS) plummets to 25 (ish) instantly just gets lower and lower until it hits around 1 FPS.
If I was to use the same loops to pass over the array but instead use say random() for ascii and colours etc and calculate the pixel coordinates manually within the loop I get 60 FPS.
How can lookup table be slower than using random / inline calculations ?!?
Thanks in advance for any feedback :)
-
Can you share the program so I can take a look please
When using 2d arrays I find it quicker to take a copy of the 2nd array i want to work with within the loop
for a = 0 to len (2darray) loop c = 2darray[a] for b = 0 to len (c) loop /// STUFF repeat repeat
-
@MikeDX said in Poor performance (single figure FPS) when using two dimensional array of structure:
Can you share the program so I can take a look please
When using 2d arrays I find it quicker to take a copy of the 2nd array i want to work with within the loop
for a = 0 to len (2darray) loop c = 2darray[a] for b = 0 to len (c) loop /// STUFF repeat repeat
Thanks for the suggestion Mike.
Just tried that method with pretty much the exact same results.
-
Actually that's compacted by it being a 2D array of structs
I'll raise an issue, we can take a look and hopefully performance will improve in a future patch.
-
@MikeDX Would you still like me share program ?
-
I'm sure @Luke would like to take a look at that program too so yes please mate!
-
I think I got the idea of what you were doing now, thank you. It's always useful to share code that breaks / does stuff as we can test against it
-
My Nintendo Switch Friend Code: SW-2370-8420-6054
Program Name: Text Console
I cannot share ATM keeping getting a "Error: No Connection" when I try (I will post here once i have succeeded)
-
There are issues with the share server at the minute but we are working on a fix. You should be able to share at the moment
-