Jump to content
prototype1479

Does white space affect performance?

Recommended Posts

17 hours ago, prototype1479 said:

Does white space affect performance? If yes or no what about in previous BI games like OFP

In your regular, run of the mill .sqf files?

No. Doubt it's even measurable unless we're talking about 200mb+ files filled with space/tab whitespaces.

 

Cheers

Share this post


Link to post
Share on other sites

I always though that people who truncate their javascript by taking off the spaces save some bandwidth when the web page script is send to client. Does arma sqf benefit from taking away spaces? I don't know.

 

Share this post


Link to post
Share on other sites
39 minutes ago, gc8 said:

I always though that people who truncate their javascript by taking off the spaces save some bandwidth when the web page script is send to client. Does arma sqf benefit from taking away spaces? I don't know.

 

Makes sense to speed up websites like that, in arma .sqf files are downloaded with the mission file and usually remain in memory.

Unless you broadcast the actual function via network, removing whitespaces in .sqf has no real benefits (unless someone else can come up with one).

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites
4 hours ago, Grumpy Old Man said:

Makes sense to speed up websites like that, in arma .sqf files are downloaded with the mission file and usually remain in memory.

Unless you broadcast the actual function via network, removing whitespaces in .sqf has no real benefits (unless someone else can come up with one).

 

I agree with Grumpy (but hate to admit that!!!).   Removing whitespace will also have the NEGATIVE effect of making the code less readable and maintainable.   I say bring on whitespace, indentation, and comments!

  • Like 3
  • Sad 1

Share this post


Link to post
Share on other sites

No it doesn't. Whitespace increases memory usage by a bit, but besides that they do nothing.

 

Scripts are compiled once and then the compiled instructions are executed. Only thing removing whitespace would do is "speed up" compile times because it has to skip over whitespace, but skipping a whitespace is like 2 CPU instructions, the speed of how fast it can do that is limited by your CPU cache size and memory speed.
Modern CPU's/RAM have a throughput in the tens of gigabytes per second range, I assume you don't have several Megabytes of whitespace in your script file.. And even if you did that would not even be a millisecond of time.

For example Intel Haswell-E wih 3200Mhz DDR4 4-channel memory has a throughput of about 60GB/s That's 60MB/ms so skipping over a whole MB of whitespace would take about 17us. Trying to optimize that is just nonsense if compiling a script already takes 500us or more.

So only performance difference could be visible if you constantly recompile your script, but at that point you are just stupid and removing a couple whitespaces won't help you with that.

  • Like 4

Share this post


Link to post
Share on other sites
12 minutes ago, Dedmen said:

Scripts are compiled once and then the compiled instructions are executed.

 

Is this really the case with arma? I have always wondered that.

 

If you write code like this:

test =
{
 hint "Test Fn";
};

 

The "test" contains code which doesn't need to be compiled but can be called.

 

Or am I wrong about this?

 

 

Share this post


Link to post
Share on other sites
7 minutes ago, gc8 said:

Is this really the case with arma? I have always wondered that.

Yes, otherwise I wouldn't have said that.

 

7 minutes ago, gc8 said:

The "test" contains code which doesn't need to be compiled but can be called.

Yes. But Arma stores the original input string so that it can give it back to you when you call "str test", because it cannot turn the compiled instructions back into string. That's also why whitespace increases memory usage as the original input string is always kept together with the compiled code.

  • Like 1

Share this post


Link to post
Share on other sites
7 minutes ago, Dedmen said:

Yes, otherwise I wouldn't have said that.

 

So how you know? I have to ask

Share this post


Link to post
Share on other sites
37 minutes ago, Dedmen said:

So only performance difference could be visible if you constantly recompile your script, but at that point you are just stupid and removing a couple whitespaces won't help you with that.

 

- Isn't it the case when you execVM an sqf, a widely shared method?

- What about comments? Some of them can have several lines, if not saying a great percentage of the whole code.

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, gc8 said:

So how you know? I have to ask

Passionate Arma hacker that already got his Battleye ban. Don't attempt.

 

1 hour ago, pierremgi said:

- Isn't it the case when you execVM an sqf, a widely shared method?

Yes. Sadly. You shouldn't use execVM for anything that's executed more than once, that's what CfgFunction was made for.

 

1 hour ago, pierremgi said:

- What about comments? Some of them can have several lines, if not saying a great percentage of the whole code.

They are removed at preprocess stage, before compile.

  • Like 3
  • Haha 2

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×