Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ github "JohnSundell/Unbox" "master"
github "SwiftyJSON/SwiftyJSON" "master"
github "Anviking/Decodable" "master"
github "Hearst-DD/ObjectMapper" ~> 2.2
github "vdka/json" ~> 0.15
github "vdka/json" ~> 0.16
github "hkellaway/Gloss" "master"
github "LoganWright/Genome" == 3.0.3
github "postmates/PMJSON" "master"
6 changes: 3 additions & 3 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
github "Anviking/Decodable" "5cbd5cf2a13376e11f8c8808c437c7e8f9e45e27"
github "Anviking/Decodable" "0a59e61d2522dc2f42f3b9f636dcce3869651c92"
github "LoganWright/Genome" "3.0.3"
github "hkellaway/Gloss" "731d09219477c1765505473af6d5152dc968d778"
github "utahiosmac/Marshal" "ba0c55e5edfc216aae486229f6f5456ce3db4473"
github "Hearst-DD/ObjectMapper" "2.2.1"
github "postmates/PMJSON" "2857cd48632974c0e3b79f9c05d3a07cfd6f637b"
github "SwiftyJSON/SwiftyJSON" "ffbc7e4b8ee0e9ec76966007e7a7bef659aea284"
github "SwiftyJSON/SwiftyJSON" "1dc2ce0f913b27380cd5b803af8aa853745b9608"
github "JohnSundell/Unbox" "ac69e55c85a7d7e155b06c001bcbea26c19f3375"
github "vdka/json" "0.15.0"
github "vdka/json" "0.16.2"
github "lyft/mapper" "8f5b51bee8627eaa162eb42953ef0a6521880041"
32 changes: 32 additions & 0 deletions JSONShootout.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@
20A0B9591DC25B60001D8A14 /* Program+Genome.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A0B9581DC25B60001D8A14 /* Program+Genome.swift */; };
20A0B95B1DC25F03001D8A14 /* Genome_Test.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20A0B95A1DC25F03001D8A14 /* Genome_Test.swift */; };
20A0B96B1DC26810001D8A14 /* GenomeFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 20A0B9691DC26803001D8A14 /* GenomeFoundation.framework */; };
20BB48341DD223FC00B72AE5 /* User+Genome.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20BB48331DD223FC00B72AE5 /* User+Genome.swift */; };
20BB48361DD232D100B72AE5 /* User+Gloss.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20BB48351DD232D100B72AE5 /* User+Gloss.swift */; };
20BB48381DD2440F00B72AE5 /* User+Mapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20BB48371DD2440F00B72AE5 /* User+Mapper.swift */; };
20BB483A1DD247C200B72AE5 /* User+Decodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20BB48391DD247C200B72AE5 /* User+Decodable.swift */; };
5B69A1DA1DBEC84200B12579 /* Recording+Decodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B69A1D91DBEC84200B12579 /* Recording+Decodable.swift */; };
5B69A1DC1DBEC86A00B12579 /* Program+Decodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B69A1DB1DBEC86A00B12579 /* Program+Decodable.swift */; };
5B69A1DE1DBEC9A400B12579 /* Decodable_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B69A1DD1DBEC9A400B12579 /* Decodable_Tests.swift */; };
5BA72ECF1DBECC0C007ADBAE /* ModelObjects.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC97869E1CEBABE7005A5DEA /* ModelObjects.framework */; };
5BA72ED31DBECD52007ADBAE /* Decodable.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5BA72EC71DBECA48007ADBAE /* Decodable.framework */; };
5DA29ACC1DC733B100345728 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DA29ACB1DC733B100345728 /* User.swift */; };
5DA29ACE1DC733D800345728 /* User+JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DA29ACD1DC733D800345728 /* User+JSON.swift */; };
5DA29AD01DC7347100345728 /* User+Marshal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DA29ACF1DC7347100345728 /* User+Marshal.swift */; };
5DA29AD21DC7384100345728 /* Users.json in Resources */ = {isa = PBXBuildFile; fileRef = 5DA29AD11DC7384100345728 /* Users.json */; };
681299051DBFFCAB009960BE /* ObjectMapper.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 681299041DBFFCAB009960BE /* ObjectMapper.framework */; };
681299061DBFFCAB009960BE /* ObjectMapper.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 681299041DBFFCAB009960BE /* ObjectMapper.framework */; };
681299071DBFFCBC009960BE /* ObjectMapper.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 681299041DBFFCAB009960BE /* ObjectMapper.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
Expand Down Expand Up @@ -128,10 +136,18 @@
20A0B9581DC25B60001D8A14 /* Program+Genome.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Program+Genome.swift"; sourceTree = "<group>"; };
20A0B95A1DC25F03001D8A14 /* Genome_Test.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Genome_Test.swift; sourceTree = "<group>"; };
20A0B9691DC26803001D8A14 /* GenomeFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = GenomeFoundation.framework; sourceTree = BUILT_PRODUCTS_DIR; };
20BB48331DD223FC00B72AE5 /* User+Genome.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "User+Genome.swift"; sourceTree = "<group>"; };
20BB48351DD232D100B72AE5 /* User+Gloss.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "User+Gloss.swift"; sourceTree = "<group>"; };
20BB48371DD2440F00B72AE5 /* User+Mapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "User+Mapper.swift"; sourceTree = "<group>"; };
20BB48391DD247C200B72AE5 /* User+Decodable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "User+Decodable.swift"; sourceTree = "<group>"; };
5B69A1D91DBEC84200B12579 /* Recording+Decodable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Recording+Decodable.swift"; sourceTree = "<group>"; };
5B69A1DB1DBEC86A00B12579 /* Program+Decodable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Program+Decodable.swift"; sourceTree = "<group>"; };
5B69A1DD1DBEC9A400B12579 /* Decodable_Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Decodable_Tests.swift; sourceTree = "<group>"; };
5BA72EC71DBECA48007ADBAE /* Decodable.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Decodable.framework; sourceTree = BUILT_PRODUCTS_DIR; };
5DA29ACB1DC733B100345728 /* User.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
5DA29ACD1DC733D800345728 /* User+JSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "User+JSON.swift"; sourceTree = "<group>"; };
5DA29ACF1DC7347100345728 /* User+Marshal.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "User+Marshal.swift"; sourceTree = "<group>"; };
5DA29AD11DC7384100345728 /* Users.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Users.json; sourceTree = "<group>"; };
681299041DBFFCAB009960BE /* ObjectMapper.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = ObjectMapper.framework; sourceTree = BUILT_PRODUCTS_DIR; };
681299171DC00DB1009960BE /* ObjectMapper_Test.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ObjectMapper_Test.swift; sourceTree = "<group>"; };
681299191DC00DBB009960BE /* Program+ObjectMapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Program+ObjectMapper.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -302,6 +318,7 @@
AA2B38D31DC0B6D3008CECCD /* JSON_Tests.swift */,
9E9BF9CB1DCD11BA00548161 /* PMJSON_Tests.swift */,
CC5A1A4C1CEAE182007238F3 /* Large.json */,
5DA29AD11DC7384100345728 /* Users.json */,
CC5A1A181CEADE59007238F3 /* Info.plist */,
);
path = JSONShootoutTests;
Expand All @@ -314,6 +331,7 @@
CC9786A21CEBABE7005A5DEA /* Info.plist */,
CC9786BB1CEBAC14005A5DEA /* Recording.swift */,
CC9786BD1CEBAC21005A5DEA /* Program.swift */,
5DA29ACB1DC733B100345728 /* User.swift */,
CC9786BF1CEBAC6C005A5DEA /* NSDate+JSON.swift */,
71337C8A1DBEBC6B00DCA374 /* Recording+Marshal.swift */,
71337C8C1DBEBC7900DCA374 /* Recording+Mapper.swift */,
Expand All @@ -335,6 +353,12 @@
7C3FCD301DC1B2A100C82DEE /* Program+Gloss.swift */,
20A0B9581DC25B60001D8A14 /* Program+Genome.swift */,
9E9BF9CD1DCD126D00548161 /* Program+PMJSON.swift */,
5DA29ACD1DC733D800345728 /* User+JSON.swift */,
5DA29ACF1DC7347100345728 /* User+Marshal.swift */,
20BB48331DD223FC00B72AE5 /* User+Genome.swift */,
20BB48351DD232D100B72AE5 /* User+Gloss.swift */,
20BB48371DD2440F00B72AE5 /* User+Mapper.swift */,
20BB48391DD247C200B72AE5 /* User+Decodable.swift */,
);
path = ModelObjects;
sourceTree = "<group>";
Expand Down Expand Up @@ -468,6 +492,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5DA29AD21DC7384100345728 /* Users.json in Resources */,
CC5A1A4D1CEAE182007238F3 /* Large.json in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -514,25 +539,32 @@
files = (
71337C8F1DBEBC8600DCA374 /* Recording+Unbox.swift in Sources */,
6812991C1DC00DBB009960BE /* Recording+ObjectMapper.swift in Sources */,
20BB48341DD223FC00B72AE5 /* User+Genome.swift in Sources */,
71337C971DBEBFD000DCA374 /* Program+Unbox.swift in Sources */,
CC9786BE1CEBAC21005A5DEA /* Program.swift in Sources */,
71337C8D1DBEBC7900DCA374 /* Recording+Mapper.swift in Sources */,
20BB483A1DD247C200B72AE5 /* User+Decodable.swift in Sources */,
5DA29ACE1DC733D800345728 /* User+JSON.swift in Sources */,
6812991B1DC00DBB009960BE /* Program+ObjectMapper.swift in Sources */,
9E9BF9D01DCD307200548161 /* Recording+PMJSON.swift in Sources */,
71337C991DBEBFDC00DCA374 /* Program+SwiftyJSON.swift in Sources */,
71337C931DBEBFB400DCA374 /* Program+Marshal.swift in Sources */,
CC9786C01CEBAC6C005A5DEA /* NSDate+JSON.swift in Sources */,
9E9BF9CE1DCD126D00548161 /* Program+PMJSON.swift in Sources */,
5B69A1DA1DBEC84200B12579 /* Recording+Decodable.swift in Sources */,
5DA29ACC1DC733B100345728 /* User.swift in Sources */,
AA2B38D01DC0B4D2008CECCD /* Program+JSON.swift in Sources */,
7C3FCD311DC1B2A100C82DEE /* Program+Gloss.swift in Sources */,
5B69A1DC1DBEC86A00B12579 /* Program+Decodable.swift in Sources */,
5DA29AD01DC7347100345728 /* User+Marshal.swift in Sources */,
7C3FCD331DC1B2AE00C82DEE /* Recording+Gloss.swift in Sources */,
AA2B38D21DC0B57F008CECCD /* Recording+JSON.swift in Sources */,
71337C911DBEBCA300DCA374 /* Recording+SwiftyJSON.swift in Sources */,
20A0B9571DC2584D001D8A14 /* Recording+Genome.swift in Sources */,
20BB48381DD2440F00B72AE5 /* User+Mapper.swift in Sources */,
71337C951DBEBFC300DCA374 /* Program+Mapper.swift in Sources */,
71337C8B1DBEBC6B00DCA374 /* Recording+Marshal.swift in Sources */,
20BB48361DD232D100B72AE5 /* User+Gloss.swift in Sources */,
20A0B9591DC25B60001D8A14 /* Program+Genome.swift in Sources */,
CC9786BC1CEBAC14005A5DEA /* Recording.swift in Sources */,
);
Expand Down
20 changes: 13 additions & 7 deletions JSONShootoutTests/Decodable_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ import ModelObjects
import Decodable

class Decodable_Tests: XCTestCase {

func testDeserialization() {
self.measure {
let d:NSDictionary = try! JSONSerialization.jsonObject(with: self.data as Data, options: []) as! NSDictionary
XCTAssert(d.count > 0)
}
}

func testPerformance() {
let dict = try! JSONSerialization.jsonObject(with: self.data as Data, options: []) as! NSDictionary
Expand All @@ -28,11 +21,24 @@ class Decodable_Tests: XCTestCase {
}
}

func testPerformance2() {
let dict: NSArray = try! JSONSerialization.jsonObject(with: self.usersData as Data, options: []) as! NSArray
self.measure {
let users: [User] = try! [User].decode(dict)
XCTAssert(users.count > 100)
}
}

private lazy var data:Data = {
let path = Bundle(for: type(of: self)).url(forResource: "Large", withExtension: "json")
let data = try! Data(contentsOf: path!)
return data
}()

private lazy var usersData:Data = {
let path = Bundle(for: type(of: self)).url(forResource: "Users", withExtension: "json")
let data = try! Data(contentsOf: path!)
return data
}()

}
15 changes: 14 additions & 1 deletion JSONShootoutTests/Genome_Test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ class Genome_Test: XCTestCase {
}
let programs: [Program] = try! [Program](node: datas)
XCTAssert(programs.count > 1000)

}
}

func testPerformance2() {
let json = try! self.usersData.makeNode()
self.measure {
let users: [User] = try! [User](node: json)
XCTAssert(users.count > 100)
}
}

Expand All @@ -32,4 +39,10 @@ class Genome_Test: XCTestCase {
return data
}()

private lazy var usersData:Data = {
let path = Bundle(for: type(of: self)).url(forResource: "Users", withExtension: "json")
let data = try! Data(contentsOf: path!)
return data
}()

}
16 changes: 15 additions & 1 deletion JSONShootoutTests/Gloss_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,24 @@ class Gloss_Tests: XCTestCase {
}
}

func testPerformance2() {
let dict: [[String: Any]] = try! JSONSerialization.jsonObject(with: self.usersData, options: []) as! [[String: Any]]

self.measure {
let users: [User] = [User].from(jsonArray: dict) ?? []
XCTAssert(users.count > 100)
}
}

private lazy var data:Data = {
let path = Bundle(for: type(of: self)).url(forResource: "Large", withExtension: "json")
let data = try! Data(contentsOf: path!)
return data
}()


private lazy var usersData:Data = {
let path = Bundle(for: type(of: self)).url(forResource: "Users", withExtension: "json")
let data = try! Data(contentsOf: path!)
return data
}()
}
38 changes: 38 additions & 0 deletions JSONShootoutTests/JSON_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,48 @@ class JSON_Tests: XCTestCase {
}
}

func testDeserialization2() {
self.measure {
do {

let json = try JSON.Parser.parse(self.usersData)

XCTAssert((json.array?.count ?? 0) > 0)
} catch {
XCTFail("Failed to parse: \(error)")
}
}
}

func testPerformance2() {
do {

let json = try JSON.Parser.parse(self.usersData)

self.measure {
do {

let users = try json.map(User.init)
XCTAssert(users.count > 100)
} catch {
XCTFail("Mapping did fail: \(error)")
}
}
} catch {
XCTFail("Failed to parse: \(error)")
}
}

private lazy var data:Data = {
let path = Bundle(for: type(of: self)).url(forResource: "Large", withExtension: "json")
let data = try! Data(contentsOf: path!)
return data
}()

private lazy var usersData:Data = {
let path = Bundle(for: type(of: self)).url(forResource: "Users", withExtension: "json")
let data = try! Data(contentsOf: path!)
return data
}()

}
21 changes: 14 additions & 7 deletions JSONShootoutTests/Mapper_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ import Mapper

class Mapper_Tests: XCTestCase {

func testDeserialization() {
self.measure {
let d:NSDictionary = try! JSONSerialization.jsonObject(with:self.data, options: []) as! NSDictionary
XCTAssert(d.count > 0)
}
}

func testPerformance() {

let dict = try! JSONSerialization.jsonObject(with: self.data as Data, options: []) as! NSDictionary
Expand All @@ -30,10 +23,24 @@ class Mapper_Tests: XCTestCase {
}
}

func testPerformance2() {
let dict: NSArray = try! JSONSerialization.jsonObject(with: self.usersData as Data, options: []) as! NSArray
self.measure {
let users: [User] = User.from(dict)!
XCTAssert(users.count > 100)
}
}

private lazy var data:Data = {
let path = Bundle(for: type(of: self)).url(forResource: "Large", withExtension: "json")!
let data = try! Data(contentsOf: path)
return data
}()

private lazy var usersData:Data = {
let path = Bundle(for: type(of: self)).url(forResource: "Users", withExtension: "json")
let data = try! Data(contentsOf: path!)
return data
}()

}
55 changes: 47 additions & 8 deletions JSONShootoutTests/Marshal_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,78 @@ class Marshal_Tests: XCTestCase {
XCTAssert(d.count > 0)
}
}

func testTypedDeserialization() {
self.measure {
let json = try! JSONParser.JSONObjectWithData(self.data as Data)
XCTAssert(json.count > 0)
}
}

func testDictionaryPerformance() {
let json = try! JSONParser.JSONObjectWithData(data as Data)

self.measure {
let programs:[Program] = try! json.value(for:"ProgramList.Programs")
XCTAssert(programs.count > 1000)
}
}

func testNSDictionaryPerformance() {
let json = try! JSONSerialization.jsonObject(with: self.data as Data, options: []) as! NSDictionary

self.measure {
//for _ in 0..<10 {
//while true {
let programs:[Program] = try! json.value(for: "ProgramList.Programs")
XCTAssert(programs.count > 1000)
let programs:[Program] = try! json.value(for: "ProgramList.Programs")
XCTAssert(programs.count > 1000)
//}
}
}


func testDeserialization2() {
self.measure {
let d: NSArray = try! JSONSerialization.jsonObject(with: self.usersData as Data, options: []) as! NSArray
XCTAssert(d.count > 0)
}
}

func testTypedDeserialization2() {
self.measure {
let json = try! JSONParser.JSONArrayWithData(self.usersData as Data)
XCTAssert(json.count > 0)
}
}

func testDictionaryPerformance2() {
let json = try! JSONParser.JSONArrayWithData(self.usersData as Data)

self.measure {
let users: [User] = try! json.map(User.init(object:))
XCTAssert(users.count > 100)
}
}

/*
func testNSDictionaryPerformance2() {
let json = try! JSONSerialization.jsonObject(with: self.usersData as Data, options: []) as! NSArray

self.measure {
let users: [User] = try! json.map(User.init(object:))
XCTAssert(users.count > 1000)
}
}
*/

private lazy var data:Data = {
let path = Bundle(for: type(of: self)).url(forResource: "Large", withExtension: "json")
let data = try! Data(contentsOf: path!)
return data
}()

private lazy var usersData:Data = {
let path = Bundle(for: type(of: self)).url(forResource: "Users", withExtension: "json")
let data = try! Data(contentsOf: path!)
return data
}()
}
Loading