Topic:   SC Array Speed Test   (Read 13898 times)


0 Members and 1 Guest are viewing this topic.

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
SC Array Speed Test
« on: February 19, 2011, 08:18:26 PM »
SC Array Speed Test
Video of the tests in action.

This compares a nthfield array to a real array. It runs each test 10,000 times. Storing the number 5 in each array and retrieving the number from the array.

For these tests on my iMac I have this data:
- 7 ticks for the real array test.
- 136 ticks for the nthfield array test.

Real arrays are about 20* faster than nthfield arrays.
This is a substantial lag for projects that use nthfield arrays a lot.

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: SC Array Speed Test
« Reply #1 on: February 20, 2011, 12:24:22 AM »
Wow, I thought it would be a bit slower but 20* is sort of surprising.
« Last Edit: February 20, 2011, 12:24:32 AM by Connors »
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

EqwanoX


  • Administrator

  • GMG Extraordinaire

  • *****


  • Posts: 1180
Re: SC Array Speed Test
« Reply #2 on: February 20, 2011, 08:55:04 AM »
daaaaaammmnn! thats insane!

lol, it takes 56ticks for number array and 519 ticks for string on my g5

HOLY SHlT, ive used a FOR loop before for replaceing specific fields, but not as a method, just raw code, and even though its virtually the SAME, for some reason redds code as a method runs insanly faster, i couldnt even get a reading on it, it just kept going, i had to force quit, thats so fucking wierd, now i have to go back and modify my for loops as methods

to be fair though, i dont see a circumstance where you would constantly replace specific fields like this, i think it would only be for specific circumstances like purchasing something that increases a stat .

holy shit, useing number arrays is faster than useing number variables! so let x(1)=5 is faster than let x=5

same with strings, its about 20% faster for me! so you can make your game faster by makeing all strings and variables as arrays even if your storing just one value




Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: SC Array Speed Test
« Reply #3 on: February 20, 2011, 09:26:10 AM »
How interesting...

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: SC Array Speed Test
« Reply #4 on: February 20, 2011, 04:45:48 PM »
Quote
same with strings, its about 20% faster for me! so you can make your game faster by makeing all strings and variables as arrays even if your storing just one value
Aye, but with the possible exception of TD I doubt players can physically click things fast enough to notice a difference.
I survived the spammage of 2007

GMG Mike


  • Administrator

  • GMG-er

  • *****

  • no avatar

  • Posts: 536
    • mikerichardson.name
Re: SC Array Speed Test
« Reply #5 on: February 20, 2011, 07:03:07 PM »
There's no logical reason why number arrays would be faster than number variables. It takes more work (within the runtime) to modify a value in the number array.

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: SC Array Speed Test
« Reply #6 on: February 20, 2011, 07:06:06 PM »
Logic be damned; this isn't brain surgery, it's computer science!
I survived the spammage of 2007

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: SC Array Speed Test
« Reply #7 on: February 21, 2011, 12:07:38 AM »
Maybe arrays are faster because it's a more specific location for the computer to look up. Otherwise it gets the variable's value from a larger group (similar to what slows down fake string arrays).
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

EqwanoX


  • Administrator

  • GMG Extraordinaire

  • *****


  • Posts: 1180
Re: SC Array Speed Test
« Reply #8 on: February 21, 2011, 09:09:33 AM »
its true! check it out, in some cases 50% faster


http://www.mediafire.com/?owd5uspt8c2kxz6
« Last Edit: February 21, 2011, 09:10:36 AM by EqwanoX »

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: SC Array Speed Test
« Reply #9 on: February 21, 2011, 04:50:34 PM »
Hmm. I just tested your project and I'm getting normal variables are faster than arrays.

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: SC Array Speed Test
« Reply #10 on: February 21, 2011, 08:09:18 PM »
Say whaaaaaaaaat? ???
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

EqwanoX


  • Administrator

  • GMG Extraordinaire

  • *****


  • Posts: 1180
Re: SC Array Speed Test
« Reply #11 on: February 22, 2011, 08:49:04 AM »
you might need a restart or quit some other apps, cause even on my intel its 40% faster

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: SC Array Speed Test
« Reply #12 on: February 22, 2011, 11:00:00 AM »
Did you have the variable window opened or closed?
I'm gonna try another test.

Al Staffieri


  • GMG-er

  • **

  • no avatar

  • Posts: 452

  • I love GameMaker
Re: SC Array Speed Test
« Reply #13 on: February 22, 2011, 11:19:02 AM »
Arrays were faster for me with EQ's test.

GMG Mike


  • Administrator

  • GMG-er

  • *****

  • no avatar

  • Posts: 536
    • mikerichardson.name
Re: SC Array Speed Test
« Reply #14 on: February 22, 2011, 06:23:45 PM »
On the Mac Pro both of eq's tests take 1 tick  :D

I increased the number of times from 1,000 to 100,000. This gives a more accurate result.

SilverCreator v2.0b3.1

VARIABLES WINDOW OPEN
Variable: 114 ticks
Variable Array: 73 ticks

VARIABLES WINDOW CLOSED
Variable: 15 ticks
Variable Array: 19 ticks

COMPILED GAME:
Variable: 14 ticks
Variable Array: 17 ticks