playMaker

Author Topic: Speed of X solution versus Y when formatting a string  (Read 1214 times)

szomaza

  • Sr. Member
  • ****
  • Posts: 253
Speed of X solution versus Y when formatting a string
« on: February 06, 2017, 12:25:28 PM »
Hi All,

I have a general question about how do programmers know which solution to code when faced with a problem when there are several different ways to achieve the same result?

(I only use Playmaker, don't code.)
I could implement both ways and run them a zillion times and measure it or watch profiler, then I would know which one is faster, but is there a more CLEVER step by step evaluative way to judge which solution would run faster?

The task I need to solve is that I'll have a bunch of integers in string format. All between 0 and 999 and I need to make them into 3 length strings.
e.g.:
1 should be 001,
56 should be 056,
258 will remain 258.

With playmaker I could simply get this result by, converting the string to int and then from int back to string with using 000 formating.
This would be very easy to set up in one state but I fear because of the string-int-string conversion it might run quite slow.

The other way would be to check the length of the string, then Int Switch 1,2 or 3 length and then use a bit different build string for the first 2 and nothing when it is already 3 long.
This would require many more states, but might actually run faster in the end.

Any words of wisdom, how a programmer would think about which method to use? Which will run faster?



Thanks in advance,
szomaza