As I dive deeper into Swift performance and in memory representation, I realize that more context can be helpful.
My background is c/c++. so I'm looking to thoroughly understand the underlying behavior.
I see not my test might be overly simplified compared to the production code. It may be that swift can do much more optimization of a struct with an 80K array than it might with nesting of struct that have multiple variable length arrays in them.
I'll change my test to explore these options.
As an example, here is roughly what the source data looks like in swift. (Yes, it is a fairly naive generated codable interpretation of the JSON.)
All feedback and insights appreciated.
import Foundation
struct EventData: Codable {
var events: [Event]
var featuredItems: [FeaturedItem]
}
struct Event: Codable {
var isAvailable: Bool
var name: String
var competitionName: String
var competitionId: String
var teams: [Team]
var markets: [Market]
}
struct Team: Codable {
var name: String
var teamId: String
var players: [Player]
}
struct Player: Codable {
var playerId: String
var parentId: String?
var isTeam: Bool
var lastName: String?
var firstName: String
var details: [PlayerDetail]
}
struct PlayerDetail: Codable {
var position: String?
var jerseyNumber: String?
}
struct Market: Codable {
var marketId: String
var marketTypeId: String
var name: String
var isSuspended: Bool
var selections: [Selection]
}
struct Selection: Codable {
var selectionId: String
var handicap: Double
var competitorId: String
var name: String
var odds: Odds
var competitor: Competitor
}
struct Odds: Codable {
var decimal: Double
var numerator: Int
var denominator: Int
}
struct Competitor: Codable {
var competitorId: String
var parentId: String?
var isTeam: Bool
var name: String
var details: [CompetitorDetail]
}
struct CompetitorDetail: Codable {
var position: String?
var jerseyNumber: String?
}
struct FeaturedItem: Codable {
var lastUpdatedAt: String
var marketId: String
var marketTypeId: String
var name: String
var isSuspended: Bool
var selections: [FeaturedSelection]
}
struct FeaturedSelection: Codable {
var selectionId: String
var handicap: Double
var competitorId: String
var name: String
var odds: Odds
var competitor: Competitor
}
Topic:
Programming Languages
SubTopic:
Swift
Tags: