Post Reply 
Question about displaying strings
10-23-2019, 01:07 AM
Post: #13
RE: Question about displaying strings
I decided to explore this issue a little more, and wrote a small program testing time of the timing of center string workaround. This is a quick and dirty test routine, no fanciness involved.
(This is the first time I am trying to post the code, so, if I mess something up, my apologies.)
PHP Code:
EXPORT CENTER_TEST()
BEGIN

  LOCAL nCounter
,nBuffer,i,nX;
  
LOCAL sString:="Mary had a little lamb, whose fleece was white as snow."

  PRINT();
  PRINT(
sString);

  
nCounter:=TICKS();
  FOR 
i FROM 0 TO 10000 DO
    
DIMGROB_P(G1,320,240);
    
// TEXTOUT_P(sString,G1,0,0);
  
END;
  
nCounter:=TICKS()-nCounter;
  
nX:=TEXTOUT_P(sString,G1,0,0);
  
nBuffer:=nCounter;
  PRINT(
"\nGROB full screen\nTime: "+nCounter+", X coord.: "+nX);

  
nCounter:=TICKS();
  FOR 
i FROM 0 TO 10000 DO
    
DIMGROB_P(G1,1,1);
    
// TEXTOUT_P(sString,G1,0,0);
  
END;
  
nCounter:=TICKS()-nCounter;
  
nX:=TEXTOUT_P(sString,G1,0,0);
  PRINT(
"\nGROB one px.:\nTime: "+nCounter+", X coord.: "+nX);
  PRINT(
"\nRatio: "+nBuffer/nCounter);

END
I ran this program on real G2, not the virtual calculator.

The results slightly varied from run to run. (Is it true that HPP OS is RTOS based? That would explain it. Or is it just an effect of executing ISRs of interrupts coming to CPU during program execution?)
Regardless, my typical results were as follows:
1. For the program with printing statements disabled, allocating GROB1 full screen only was 9656 ms, while allocating GROB1 one px. was 105 ms (each 10,000 times).
2. For the program with printing statements enabled, allocating GROB1 full screen and printing the string was 13096 ms, while allocating GROB1 one px. and printing the string was 1594 ms (each 10,000 times).
Thus, if you subtract those numbers (respectively), you should get time that takes to print the string in GROB1 10,000 times. If you do it, you will see that the time of printing the screen depends on the size of the GROB.

Note: Initially I tried to allocate the GROB of (0,0). When I did it, I was occasionally getting wrong X coordinates. I did not explore it further, but there is apparently a not handled situation in the code when the area of the GROB is zero.

My conclusions:
1. The smaller the GROB, the shorter its allocation time. I am assuming this is because of GROB initialization during allocation (rather obvious conclusion...).
2. A process of printing to the undefined section of the GROB is faster than a process of printing to the defined section of the GROB.

Darius
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Question about displaying strings - DrDarius - 10-23-2019 01:07 AM



User(s) browsing this thread: 1 Guest(s)