Author Topic: Does InForm Use a lot of CPU?  (Read 5809 times)

0 Members and 1 Guest are viewing this topic.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Does InForm Use a lot of CPU?
« on: August 15, 2018, 04:53:28 am »
I thought that I would investigate SetFrameRate within InForm, as I may need to speed things up in program I'm working on.  So, within the existing program "Fireworks" (by Fellippe) I changed SetFrameRate periodically from 30 (default) to 120.  I noticed that the speed of the firework display did not change very much.  With the following code within the __UI_BeforeUpdateDisplay subroutine

Code: QB64: [Select]
  1.     Count% = Count% + 1
  2.     'PRINT #1, Count%
  3.     IF Count% = 300 THEN
  4.         IF Control(ExitBT).Hidden = False THEN
  5.             Control(ExitBT).Hidden = True
  6.             Control(ExitBT).Disabled = True
  7.             SetFrameRate 120
  8.         ELSE
  9.             Control(ExitBT).Hidden = False
  10.             Control(ExitBT).Disabled = False
  11.             SetFrameRate 30
  12.         END IF
  13.         Count% = 0
  14.         PRINT #1, TIMER - Start!
  15.         Start! = TIMER
  16.     END IF

writing to a text file, the times for 300 cycles were: 10s for SetFrameRate 30 (correct), but 7.4s for SetFrameRate 120 (should be 2.5s).  I noticed that during the SetFrameRate 120 periods the computer was running at one full CPU, which is usually indicative of the computer running at full speed.  I have a Core i5 processor, so running the Fireworks program should be using very little CPU effort.

I have noticed that the IDE is slow to update changes in an InForm program, so does InForm use a lot of CPU?

Richard

FellippeHeitor

  • Guest
Re: Does InForm Use a lot of CPU?
« Reply #1 on: August 15, 2018, 08:46:21 am »
InForm does use its share of CPU. It is constantly checking/processing input and refreshing the screen at a minimum of 30fps.

An idle InForm-based program (one that's simply showing the interface, not running any background tasks) will use between 10-15% of CPU. Compare that to the IDE that maintains an average of 35% of CPU usage when idle.

In my experience, the max frame rate I was able to achieve with an InForm program was ~90fps. Please see the observations in this thread: https://www.qb64.org/forum/index.php?topic=254

I have noticed that the IDE is slow to update changes in an InForm program, so does InForm use a lot of CPU?
I assume you mean that when you edit a .bas file generated by InForm in the IDE it takes long to indent, capitalize keywords and the like. If that's the case, it has nothing to do with InForm using a lot of CPU at runtime, but with the fact that InForm's core library is made up of a few thousand lines of code, all of which come before your program's custom code (as per the position of the $INCLUDE lines), and the IDE goes through it all before starting on your custom SUB/FUNCTION block.