[skip travis] profile date parsing

This commit is contained in:
Gwendal Roué committed 2020-11-14 13:18:21 +01:00
1 parent 4c5c2dfb6c
commit 27662f99b0
1 file changed
+42
@@ -7,6 +7,8 @@ let insertedRowCount = 20_000
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) {
try! parseDateComponents()
try! parseDates()
try! fetchValues()
try! fetchPositionalValues()
try! fetchNamedValues()
@@ -22,6 +24,46 @@ class AppDelegate: NSObject, NSApplicationDelegate {
// MARK: -
func parseDateComponents() throws {
/// Selects many dates
let request = """
WITH RECURSIVE
cnt(x) AS (
SELECT 1
UNION ALL
SELECT x+1 FROM cnt
LIMIT 50000
)
SELECT '2018-04-20 14:47:12.345' FROM cnt;
"""
try DatabaseQueue().inDatabase { db in
let cursor = try DatabaseDateComponents.fetchCursor(db, sql: request)
while try cursor.next() != nil { }
}
}
func parseDates() throws {
/// Selects many dates
let request = """
WITH RECURSIVE
cnt(x) AS (
SELECT 1
UNION ALL
SELECT x+1 FROM cnt
LIMIT 50000
)
SELECT '2018-04-20 14:47:12.345' FROM cnt;
"""
try DatabaseQueue().inDatabase { db in
let cursor = try Date.fetchCursor(db, sql: request)
while try cursor.next() != nil { }
}
}
// MARK: -
func fetchValues() throws {
let databasePath = Bundle(for: type(of: self)).path(forResource: "ProfilingDatabase", ofType: "sqlite")!
let dbQueue = try DatabaseQueue(path: databasePath)