Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add encoding/decoding performance test baselines #160

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
48 changes: 34 additions & 14 deletions Tests/TurfTests/FeatureCollectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,38 +120,58 @@ class FeatureCollectionTests: XCTestCase {
guard case .featureCollection = geojson else { return XCTFail() }
}

func testPerformanceDecodeFeatureCollection() {
let data = try! Fixture.geojsonData(from: "featurecollection")!

func testPerformanceDecodeSmallFeatureCollection() {
let johannesburg = try! Fixture.geojsonData(from: "featurecollection")!
measure {
for _ in 0...100 {
_ = try! JSONDecoder().decode(FeatureCollection.self, from: data)
_ = try! JSONDecoder().decode(FeatureCollection.self, from: johannesburg)
}
}
}

func testPerformanceEncodeFeatureCollection() {
let data = try! Fixture.geojsonData(from: "featurecollection")!
let decoded = try! JSONDecoder().decode(FeatureCollection.self, from: data)

func testPerformanceDecodeLargeFeatureCollection() {
let navajo = try! Fixture.geojsonData(from: "navajo")!
measure {
_ = try! JSONDecoder().decode(FeatureCollection.self, from: navajo)
}
}

func testPerformanceEncodeSmallFeatureCollection() {
let johannesburg = try! Fixture.geojsonData(from: "featurecollection")!
let johannesburgDecoded = try! JSONDecoder().decode(FeatureCollection.self, from: johannesburg)
measure {
for _ in 0...100 {
_ = try! JSONEncoder().encode(decoded)
_ = try! JSONEncoder().encode(johannesburgDecoded)
}
}
}

func testPerformanceDecodeEncodeFeatureCollection() {
let data = try! Fixture.geojsonData(from: "featurecollection")!

func testPerformanceEncodeLargeFeatureCollection() {
let navajo = try! Fixture.geojsonData(from: "navajo")!
let navajoDecoded = try! JSONDecoder().decode(FeatureCollection.self, from: navajo)
measure {
_ = try! JSONEncoder().encode(navajoDecoded)
}
}

func testPerformanceDecodeEncodeSmallFeatureCollection() {
let johannesburg = try! Fixture.geojsonData(from: "featurecollection")!
measure {
for _ in 0...100 {
let decoded = try! JSONDecoder().decode(FeatureCollection.self, from: data)
_ = try! JSONEncoder().encode(decoded)
let johannesburgDecoded = try! JSONDecoder().decode(FeatureCollection.self, from: johannesburg)
_ = try! JSONEncoder().encode(johannesburgDecoded)
}
}
}

func testPerformanceDecodeEncodeLargeFeatureCollection() {
let navajo = try! Fixture.geojsonData(from: "navajo")!
measure {
let navajoDecoded = try! JSONDecoder().decode(FeatureCollection.self, from: navajo)
_ = try! JSONEncoder().encode(navajoDecoded)
}
}

func testDecodedFeatureCollection() {
let data = try! Fixture.geojsonData(from: "featurecollection")!
let geojson = try! JSONDecoder().decode(GeoJSONObject.self, from: data)
Expand Down
8 changes: 8 additions & 0 deletions Tests/TurfTests/Fixtures/navajo.geojson

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions Turf.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@
DA39EB80201023E4004D87F7 /* Fixture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3547ECFD200C3C82009DA062 /* Fixture.swift */; };
DA39EB81201024A3004D87F7 /* dc-line.geojson in Resources */ = {isa = PBXBuildFile; fileRef = 3547ECFB200C3C82009DA062 /* dc-line.geojson */; };
DA39EB82201024A3004D87F7 /* polygon.geojson in Resources */ = {isa = PBXBuildFile; fileRef = 3547ECFC200C3C82009DA062 /* polygon.geojson */; };
DA4A8EDB27059C490071C85C /* navajo.geojson in Resources */ = {isa = PBXBuildFile; fileRef = DA4A8EDA27059C480071C85C /* navajo.geojson */; };
DA4A8EDC27059C490071C85C /* navajo.geojson in Resources */ = {isa = PBXBuildFile; fileRef = DA4A8EDA27059C480071C85C /* navajo.geojson */; };
DA4A8EDD27059C490071C85C /* navajo.geojson in Resources */ = {isa = PBXBuildFile; fileRef = DA4A8EDA27059C480071C85C /* navajo.geojson */; };
DA9424A32010296300CDB4E6 /* Turf.h in Headers */ = {isa = PBXBuildFile; fileRef = 3547ECEF200C3C78009DA062 /* Turf.h */; settings = {ATTRIBUTES = (Public, ); }; };
DA9424A42010298300CDB4E6 /* CoreLocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3547ECF0200C3C78009DA062 /* CoreLocation.swift */; };
DA9424A52010298300CDB4E6 /* Turf.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3547ECF1200C3C78009DA062 /* Turf.swift */; };
Expand Down Expand Up @@ -257,6 +260,7 @@
CE7F8163215182FF00A9D221 /* BoundingBoxTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoundingBoxTests.swift; sourceTree = "<group>"; };
DA39EB6520101F98004D87F7 /* Turf.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Turf.framework; sourceTree = BUILT_PRODUCTS_DIR; };
DA39EB6D20101F99004D87F7 /* TurfTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TurfTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
DA4A8EDA27059C480071C85C /* navajo.geojson */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = navajo.geojson; sourceTree = "<group>"; };
DA94249B2010283900CDB4E6 /* Turf.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Turf.framework; sourceTree = BUILT_PRODUCTS_DIR; };
DA972D7926FEB9DC009F5615 /* simplify */ = {isa = PBXFileReference; lastKnownFileType = folder; path = simplify; sourceTree = "<group>"; };
DA972D922702763B009F5615 /* JSON.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSON.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -395,6 +399,7 @@
2B5FABFB24066EA5008A285F /* geometry-collection.geojson */,
357495BD208E3432007D7477 /* featurecollection.geojson */,
C46809D52124199500BAD5E1 /* featurecollection-no-properties.geojson */,
DA4A8EDA27059C480071C85C /* navajo.geojson */,
);
path = Fixtures;
sourceTree = "<group>";
Expand Down Expand Up @@ -680,6 +685,7 @@
buildActionMask = 2147483647;
files = (
C46809D821249E8F00BAD5E1 /* featurecollection-no-properties.geojson in Resources */,
DA4A8EDC27059C490071C85C /* navajo.geojson in Resources */,
3534C3BB200C419200F93581 /* polygon.geojson in Resources */,
DA972D7B26FEB9DD009F5615 /* simplify in Resources */,
3516685B202EFE690032A97E /* multiline.geojson in Resources */,
Expand All @@ -705,6 +711,7 @@
buildActionMask = 2147483647;
files = (
C46809D721241B5100BAD5E1 /* featurecollection-no-properties.geojson in Resources */,
DA4A8EDB27059C490071C85C /* navajo.geojson in Resources */,
3534C3B9200C419100F93581 /* polygon.geojson in Resources */,
DA972D7A26FEB9DC009F5615 /* simplify in Resources */,
3516685A202EFE690032A97E /* multiline.geojson in Resources */,
Expand All @@ -730,6 +737,7 @@
buildActionMask = 2147483647;
files = (
C46809D921249E9700BAD5E1 /* featurecollection-no-properties.geojson in Resources */,
DA4A8EDD27059C490071C85C /* navajo.geojson in Resources */,
DA39EB82201024A3004D87F7 /* polygon.geojson in Resources */,
DA972D7C26FEB9DD009F5615 /* simplify in Resources */,
3516685C202EFE690032A97E /* multiline.geojson in Resources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>classNames</key>
<dict>
<key>FeatureCollectionTests</key>
<dict>
<key>testPerformanceDecodeEncodeLargeFeatureCollection()</key>
<dict>
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
<dict>
<key>baselineAverage</key>
<real>0.18164</real>
<key>baselineIntegrationDisplayName</key>
<string>Local Baseline</string>
</dict>
</dict>
<key>testPerformanceDecodeEncodeSmallFeatureCollection()</key>
<dict>
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
<dict>
<key>baselineAverage</key>
<real>0.188</real>
<key>baselineIntegrationDisplayName</key>
<string>Local Baseline</string>
</dict>
</dict>
<key>testPerformanceDecodeLargeFeatureCollection()</key>
<dict>
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
<dict>
<key>baselineAverage</key>
<real>0.10472</real>
<key>baselineIntegrationDisplayName</key>
<string>Local Baseline</string>
</dict>
</dict>
<key>testPerformanceDecodeSmallFeatureCollection()</key>
<dict>
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
<dict>
<key>baselineAverage</key>
<real>0.0946</real>
<key>baselineIntegrationDisplayName</key>
<string>Local Baseline</string>
</dict>
</dict>
<key>testPerformanceEncodeLargeFeatureCollection()</key>
<dict>
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
<dict>
<key>baselineAverage</key>
<real>0.0888</real>
<key>baselineIntegrationDisplayName</key>
<string>Local Baseline</string>
</dict>
</dict>
<key>testPerformanceEncodeSmallFeatureCollection()</key>
<dict>
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
<dict>
<key>baselineAverage</key>
<real>0.0677</real>
<key>baselineIntegrationDisplayName</key>
<string>Local Baseline</string>
</dict>
</dict>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>runDestinationsByUUID</key>
<dict>
<key>25DA1DF9-97A8-4A44-B9B8-9B67B2DB942F</key>
<dict>
<key>localComputer</key>
<dict>
<key>busSpeedInMHz</key>
<integer>100</integer>
<key>cpuCount</key>
<integer>1</integer>
<key>cpuKind</key>
<string>Dual-Core Intel Core i5</string>
<key>cpuSpeedInMHz</key>
<integer>2800</integer>
<key>logicalCPUCoresPerPackage</key>
<integer>4</integer>
<key>modelCode</key>
<string>MacBookPro11,1</string>
<key>physicalCPUCoresPerPackage</key>
<integer>2</integer>
<key>platformIdentifier</key>
<string>com.apple.platform.macosx</string>
</dict>
<key>targetArchitecture</key>
<string>x86_64</string>
</dict>
</dict>
</dict>
</plist>