How to economize Expensive Ops

DateFormater example

I found this set of great articles on the expensive use of DataFormatter in Swift.

It is so very well written and researched by Sarun — an iOS developer.

Part one in a series on DateFormatter performance. In the first part, we will answer how expensive is DateFormatter and which operation is costly.

  1. How expensive is DateFormatter

  2. How to use DateFormatter in Swift

In the next article, we will use this knowledge and see how we should use DateFormatter in our code.

If you want the code.... copy/paste from the original articles.

Digging a bit deeper into my bigger domain problem... it comes down to how to represent Stock Market data in a TimeSeries inside of Swift. Such that when plotted the price data does not display the weekends and holidays. I've found that if my data has a date object, the plotting will naturally display ever day of the Calendar (which includes weekends & holidays). This is not done on most any Stock chart. So how do "they" do it?

I'm guessing - as I've never had to code a graph for this type of data. I think one must get ridde of the Date, and move to a more domain-specific-language (DSL) construct. I'd guess this is called a "market-day index" - make up a counting... start at an Epic - say the Unix timestamp Jan 1, 1970. Then start counning only days the market was open. Or restart at ONE ever January 1st, except in the USA where that is a holiday. Oh boy, the rules are going to be as clear as Baseball's forth out rule.

I sense that Python coders may just import the Pandas library to handle timeseries. Are there any similar frameworks for Swift?
Working with Time Series


Some resources I found for Pandas:

https://levelup.gitconnected.com/time-series-basics-with-pandas-f74cab9923bb
https://developers.arcgis.com/python/guide/part5-time-series-analysis-with-pandas/

https://jakevdp.github.io/PythonDataScienceHandbook/03.11-working-with-time-series.html