YouTube increases FreeBASIC performance (solved)

General FreeBASIC programming questions.
Post Reply
Provoni
Posts: 514
Joined: Jan 05, 2014 12:33
Location: Belgium

YouTube increases FreeBASIC performance (solved)

Post by Provoni »

Hey all,

Having YouTube open in Google Chrome increases the multi-threaded performance of my FreeBASIC program by about 5%. It does not happen with other web sites. Tested multiple times so this is not because of the margin of error and I have noticed this over a period of about 2 years.

I am stupefied, what is going on here?

* Having YouTube open in Microsoft Edge does NOT increase multi-threaded performance of my FreeBASIC program.
Last edited by Provoni on Oct 19, 2019 13:01, edited 1 time in total.
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: YouTube increases FreeBASIC performance

Post by jj2007 »

Certain browsers allow YouTube to set the internal resolution of the timer to a lower value, as discussed here. See also this FB thread:
jj:
some applications, notably Firefox, have the bad habit to set 1 ms resolution when playing videos on YouTube etc, and that's a system-wide setting
dodicat:
Google chrome is another to make sleep 1 = 1 ms
Are you using timers in your programs? If so, have a look at TimeBeginPeriod.
marcov
Posts: 3462
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: YouTube increases FreeBASIC performance

Post by marcov »

This is normal. Default Windows settings are power saving. The increased demand on CPU causes the CPU to increase its frequency. The algorithms for that are complex and can't always be predicted easily.

You can however indicate that you want a higher performance profile (e.g. for benchmarking). Go to control panel (alt-I) then to system->power and then on the right, click the first option (additional power settings) and set to high performance. Sometimes you need to unhide the profiles below the bar to find "high performance".
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: YouTube increases FreeBASIC performance

Post by Tourist Trap »

marcov wrote:This is normal. Default Windows settings are power saving. The increased demand on CPU causes the CPU to increase its frequency. The algorithms for that are complex and can't always be predicted easily.

You can however indicate that you want a higher performance profile (e.g. for benchmarking). Go to control panel (alt-I) then to system->power and then on the right, click the first option (additional power settings) and set to high performance. Sometimes you need to unhide the profiles below the bar to find "high performance".
Hi marcov,

I don't have those options where you point it (french version I suppose). However if I click at the battery icon on the taskbar I can set the mode to "optimal performance" rather than "autonomy first" or "medium", (I translate approximatively from french. Is this equivalent to the settings you mentionned?
Provoni
Posts: 514
Joined: Jan 05, 2014 12:33
Location: Belgium

Re: YouTube increases FreeBASIC performance

Post by Provoni »

jj2007 wrote:Certain browsers allow YouTube to set the internal resolution of the timer to a lower value, as discussed here. See also this FB thread:
jj:
some applications, notably Firefox, have the bad habit to set 1 ms resolution when playing videos on YouTube etc, and that's a system-wide setting
dodicat:
Google chrome is another to make sleep 1 = 1 ms
Are you using timers in your programs? If so, have a look at TimeBeginPeriod.
Thanks allot jj2007, this is the cause, I have confirmed it by changing the sleep values.
fxm
Moderator
Posts: 12107
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: YouTube increases FreeBASIC performance (solved)

Post by fxm »

That's why I still have a reluctance to use SLEEP with a value <15 ms (under Windows), because the actual value applied may depend on the context (timeBeginPeriod()/timeEndPeriod() not multitasking safe).
mrToad
Posts: 430
Joined: Jun 07, 2005 23:03
Location: USA
Contact:

Re: YouTube increases FreeBASIC performance (solved)

Post by mrToad »

fxm wrote:That's why I still have a reluctance to use SLEEP with a value <15 ms (under Windows), because the actual value applied may depend on the context (timeBeginPeriod()/timeEndPeriod() not multitasking safe).
After I read this I went and tested something: If Sleep(16,1) gives right around a desired 60 FPS for a game, is this more trustworthy/stable than using the functions mentioned, such as:

Code: Select all

Do: timeBeginPeriod(1) : Sleep(1,1): timeEndPeriod(1) : Loop Until (Timer - time_start) >= (1/60)
I haven't tested on multiple systems yet, but Sleep(16,1) is pretty stable in this project even while drawing a lot of graphics. If it is consistent between systems and better for multitasking, I will use it instead.
Post Reply