For years I've been using constructs like:
ToString[#] <> ".png" & /@ Range[1000]
To create a bunch of file names that I use later for exporting. I was very excited about the new StringTemplate functionality. Replacing my above code to:
StringTemplate["`1`.png"] /@ Range[1000]
Which is much neater in my opinion. The problem however is the (lack of) performance:
a = First@RepeatedTiming[ToString[#] <> ".png" & /@ Range[1000];] ;
b = First@RepeatedTiming[StringTemplate["`1`.png"] /@ Range[1000];] ;
N[b/a]
a small comparison in timing reveals that StringTemplate is roughly 130 times slower than my previous approach!! Of course 0.3 seconds is OK for a 1000 filenames. But sometimes I have 10-thousands of filenames!
Is there a way to improve the performance of StringTemplate?