Discussion

String creation cost

2

rilden 2020-08-21 11:11

According to the manual, string creation costs 1 cycle per letter.
After testing I found that string creation always costs the same, it doesn't take into account the number of letters in the string.

For example:
S1$="" costs 3 cycles, S2$="1234567890" also costs 3 cycles. S2$ should cost 13 cycles, because the string has 10 letters.

cycles.nx | Open in app
2020-08-21 11:20
cycles.nx | Open in app
2020-08-21 11:11

Timo 2020-08-21 12:13

As far as I remember, this was on purpose. Even though it's a BASIC interpreter, I wanted the CPU cycles system behave more like for machine code. In this case assigning a string to a variable is just storing a pointer to the string. Only when you edit the string, the code would usually access each character and use CPU cycles.

I will recheck my code and make it clearer in the manual.


rilden 2020-08-21 14:44

I see, I thought that string creation was referring to assignment. Thanks for clearing that up.


Log in to reply.