Author Topic: More HP Prime performance tests: Circles, Int and Random  (Read 6330 times)

0 Members and 1 Guest are viewing this topic.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
More HP Prime performance tests: Circles, Int and Random
« on: November 08, 2013, 01:29:12 am »
Anyone has any clue why the INT command is slowish? I made a program that draws 256 circles per loop, with three random commands (for the colors). Thinking that RGB didn't support decimals, I decided to use INT(). However, I got 1.5 images per second. I thought this wasn't that bad considering the three RANDOM commands, but when I removed the INT commands to see if RGB supported decimals, not only the program still worked, but now I can no longer count the frames per second I get. O.O

Code: [Select]
EXPORT CIRCLE()
BEGIN
DIMGROB_P(G1,320,240,RGB(0,0,0));
WHILE 1 DO
FOR A FROM 1 TO 255 DO
ARC_P(G1,160,120,A,RGB(255*RANDOM,255*RANDOM,255*RANDOM));
END;
BLIT_P(G0,G1);
END;
END;

Not that I am complaining, but I was wondering why the INT command had more of an impact on speed than RANDOM, considering on the 84+ it was the opposite?
« Last Edit: November 08, 2013, 01:29:45 am by DJ Omnimaga »

Offline XiiDraco

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 513
  • Rating: +32/-5
  • Forget the numbers, just call me, Recreation.
    • View Profile
    • Black-Lark Games
Re: More HP Prime performance tests: Circles, Int and Random
« Reply #1 on: November 08, 2013, 01:46:01 am »
Good Question. Maybe you could ask HP sometime :P. And It might not be the same considering it is an HP and not a Texas Instruments.

I still need to figure out how to use draw commands efficiently, and I would love to know how to use the lists too. Then I could start using the touchscreen.
« Last Edit: November 08, 2013, 01:48:39 am by XiiR3CR34T10N »

Offline Ryleh

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 16
  • Rating: +2/-0
    • View Profile
Re: More HP Prime performance tests: Circles, Int and Random
« Reply #2 on: November 08, 2013, 10:25:13 am »
My guess would be that it is an OS-related issue and that it isn't properly utilizing the hardware.

Offline timwessman

  • LV3 Member (Next: 100)
  • ***
  • Posts: 94
  • Rating: +32/-0
    • View Profile
Re: More HP Prime performance tests: Circles, Int and Random
« Reply #3 on: November 08, 2013, 12:12:28 pm »
INT is a cas command (which isn't even supposed to be in there actually as it conflicts with "int" the integration command). IP (integer part) is what you are looking for I suspect. That might make a "small" difference...

RANDOM(255) would also give you the same thing there and be sightly quicker.

Basically, any input that requires a number will correctly pull from reals, integers, or complexes.
« Last Edit: November 08, 2013, 12:36:48 pm by timwessman »
TW

Although I work for the HP calculator group, the comments and opinions I post here are my own.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: More HP Prime performance tests: Circles, Int and Random
« Reply #4 on: November 08, 2013, 08:50:33 pm »
Oh ok I was used to TI's int() command, which removes the decimal part from a number to create an integer. TI calcs also got IPart but I forgot the difference between Int() and IPart().

Also thanks for the RANDOM advice.

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: More HP Prime performance tests: Circles, Int and Random
« Reply #5 on: November 11, 2013, 06:48:07 am »
Well, Int is the mathematically defined function by n=Int(x) where n <= x < n+1 and n is an integer. IPart is the computer scientists' definition that just takes off the decimal part. You could write IPart(x) = x/|x| * Int(|x|).

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: More HP Prime performance tests: Circles, Int and Random
« Reply #6 on: November 11, 2013, 06:51:52 am »
Well, Int is the mathematically defined function by n=Int(x) where n <= x < n+1 and n is an integer. IPart is the computer scientists' definition that just takes off the decimal part. You could write IPart(x) = x/|x| * Int(|x|).;
"ERR: Division by zero" is something you could see with that code you wrote. A workaround is to replace x/|x| with sign(x), or to make a special case when x=0.
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: More HP Prime performance tests: Circles, Int and Random
« Reply #7 on: November 11, 2013, 09:01:44 am »
Yeah I knew it, but I didn't want to bother. :P

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: More HP Prime performance tests: Circles, Int and Random
« Reply #8 on: November 14, 2013, 05:22:48 pm »
Now that I know that I don't need to remove decimals for graphic commands and that INT is not the right command to use (and is slow), I decided to modify the program shown in this Critor video to compare the speed:

Here is your program video:


Now I get about 15 FPS! :D