EXPORT SELFMOD() BEGIN MSGBOX("x is "+x); Programs["SELFMOD"]:=LEFT(Programs["SELFMOD"],3)+(x+1)+MID(Programs["SELFMOD"],INSTRING(Programs["SELFMOD"],";")); END;
As you guys may know, I'm working on an application that (in a way) optimizes HPPL code. So recently, I've been time-testing several methods of computation. So if you want to know absolutely what's faster to execute, you now have this thread!
I take 10,000 to 40,000 executions of a code snippet, and average the returned execution times. All parts of the programs being tested against each other have all other variables/code held constant. This isn't EXACTLY how long each operation takes; since there's boilerplate in there, too, all the times are relative. I did all of these on a physical calculator.
Conclusion: GETPIX is slower than list access, at least for smallish indices. However, the main problem is probably the fact that you're getting back an integer, which is slow.
Big 1D Data
Let's compare strings to lists again. Let's bring this to THE MAX.
Conclusion: Setting values is much, much slower than getting them. Here, strings serve as an EXTREMELY good storage mechanism. So strings are better if you're willing to have a longer access time.
Making large strings
How does one make a large string programmatically? Well, there's the built in ΣLIST function that works, but what else can work? CHAR could do.
EXPORT TST3() BEGIN FOR I FROM 1 TO 1000 DO FF(); END; END;
The results are as follows:
MAKELIST
ITERATE
FOR
10,500 μs
7,900 μs
18,900 μs
Conclusion: If you don't care too much about the iteration count, ITERATE is better. I would bet it to be superior even if you put code in FF to make ITERATE give you back a real iteration value.
EXPORT TST3() BEGIN FOR I FROM 1 TO 1000 DO FF(I); END; END;
The results are:
MAKELIST
ITERATE
FOR
35,700 μs
39,300 μs
48,200 μs
Conclusion: Passing a parameter costs you a lot of time.
Oh, and I guess I lost that bet.
Fun fact with lists: Use LIST[0] to get the last element of a list. Set something to LIST[0] to append it to the end of the list. This is a sensible way to do things. Yessir.
Well, that's really all the useful ones I have right now. I'll do more later. Feel free to ask me for more comparisons!
Once upon a time, I was writing programs for the HP Prime in HPPL. The more I worked in HPPL, the more I became dissatisfied with the language. I mean, it was usable, but I wanted better.
So I decided to make something better. I started work on Source. It's a programming language.
Source is a procedural, statically-typed bytecode-compiled language that can either compile to whatever platform you need or interpret directly on your computer. Currently, it compiles to HPPL.
Source gives you control. It's statically typed, so you can read your code more easily. It can assume types, so it's not needlessly verbose. You can control how it compiles through directives.
Source is flexible. It provides data structures and user types. You can define methods for data types anywhere. You can organise your code into packages. Source even can handle cyclic dependencies!
Source has tools. Compile it into HPPL from the command line, or use SourceBench to write and compile code on the fly. Use SourceBox to run your code on your PC. Run SourceLine to interactively execute Source code.
Source isn't done yet. The core libraries still need implemented, not to mention a bunch of features such as custom structs and classes. In the future, it will be able to compile to a bunch of places, not just HPPL. I wouldn't describe it as 'usable' yet. But stay tuned!
Anyways, the important bit: The link. Check out the source code at: