mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-28 04:24:20 +00:00
GRDBProfiling WIP
This commit is contained in:
1 parent
243056a797
commit
ce41eba996
1 file changed
+37
-45
@@ -23,67 +23,59 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
}
|
||||
|
||||
func testValueAtIndexPerformance() {
|
||||
for _ in 0..<10 {
|
||||
dbQueue.inDatabase { db in
|
||||
for row in Row.fetch(db, "SELECT * FROM items") {
|
||||
let _: Int = row.value(atIndex: 0)
|
||||
let _: Int = row.value(atIndex: 1)
|
||||
let _: Int = row.value(atIndex: 2)
|
||||
let _: Int = row.value(atIndex: 3)
|
||||
let _: Int = row.value(atIndex: 4)
|
||||
let _: Int = row.value(atIndex: 5)
|
||||
let _: Int = row.value(atIndex: 6)
|
||||
let _: Int = row.value(atIndex: 7)
|
||||
let _: Int = row.value(atIndex: 8)
|
||||
let _: Int = row.value(atIndex: 9)
|
||||
}
|
||||
dbQueue.inDatabase { db in
|
||||
for row in Row.fetch(db, "SELECT * FROM items") {
|
||||
let _: Int = row.value(atIndex: 0)
|
||||
let _: Int = row.value(atIndex: 1)
|
||||
let _: Int = row.value(atIndex: 2)
|
||||
let _: Int = row.value(atIndex: 3)
|
||||
let _: Int = row.value(atIndex: 4)
|
||||
let _: Int = row.value(atIndex: 5)
|
||||
let _: Int = row.value(atIndex: 6)
|
||||
let _: Int = row.value(atIndex: 7)
|
||||
let _: Int = row.value(atIndex: 8)
|
||||
let _: Int = row.value(atIndex: 9)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testValueNamedPerformance() {
|
||||
for _ in 0..<10 {
|
||||
dbQueue.inDatabase { db in
|
||||
for row in Row.fetch(db, "SELECT * FROM items") {
|
||||
let _: Int = row.value(named: "i0")
|
||||
let _: Int = row.value(named: "i1")
|
||||
let _: Int = row.value(named: "i2")
|
||||
let _: Int = row.value(named: "i3")
|
||||
let _: Int = row.value(named: "i4")
|
||||
let _: Int = row.value(named: "i5")
|
||||
let _: Int = row.value(named: "i6")
|
||||
let _: Int = row.value(named: "i7")
|
||||
let _: Int = row.value(named: "i8")
|
||||
let _: Int = row.value(named: "i9")
|
||||
}
|
||||
dbQueue.inDatabase { db in
|
||||
for row in Row.fetch(db, "SELECT * FROM items") {
|
||||
let _: Int = row.value(named: "i0")
|
||||
let _: Int = row.value(named: "i1")
|
||||
let _: Int = row.value(named: "i2")
|
||||
let _: Int = row.value(named: "i3")
|
||||
let _: Int = row.value(named: "i4")
|
||||
let _: Int = row.value(named: "i5")
|
||||
let _: Int = row.value(named: "i6")
|
||||
let _: Int = row.value(named: "i7")
|
||||
let _: Int = row.value(named: "i8")
|
||||
let _: Int = row.value(named: "i9")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testRecordPerformance() {
|
||||
for _ in 0..<10 {
|
||||
let records = dbQueue.inDatabase { db in
|
||||
PerformanceRecord.fetchAll(db, "SELECT * FROM items")
|
||||
}
|
||||
precondition(records[4].i2 == 1)
|
||||
precondition(records[4].i3 == 0)
|
||||
precondition(records[5].i2 == 2)
|
||||
precondition(records[5].i3 == 1)
|
||||
let records = dbQueue.inDatabase { db in
|
||||
PerformanceRecord.fetchAll(db, "SELECT * FROM items")
|
||||
}
|
||||
assert(records[4].i2 == 1)
|
||||
assert(records[4].i3 == 0)
|
||||
assert(records[5].i2 == 2)
|
||||
assert(records[5].i3 == 1)
|
||||
}
|
||||
|
||||
func testKeyValueCodingPerformance() {
|
||||
for _ in 0..<10 {
|
||||
let records = dbQueue.inDatabase { db in
|
||||
Row.fetch(db, "SELECT * FROM items").map { row in
|
||||
PerformanceObjCRecord(dictionary: row.toNSDictionary())
|
||||
}
|
||||
let records = dbQueue.inDatabase { db in
|
||||
Row.fetch(db, "SELECT * FROM items").map { row in
|
||||
PerformanceObjCRecord(dictionary: row.toNSDictionary())
|
||||
}
|
||||
precondition(records[4].i2!.intValue == 1)
|
||||
precondition(records[4].i3!.intValue == 0)
|
||||
precondition(records[5].i2!.intValue == 2)
|
||||
precondition(records[5].i3!.intValue == 1)
|
||||
}
|
||||
assert(records[4].i2!.intValue == 1)
|
||||
assert(records[4].i3!.intValue == 0)
|
||||
assert(records[5].i2!.intValue == 2)
|
||||
assert(records[5].i3!.intValue == 1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user