mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
[skip travis] profile date parsing
This commit is contained in:
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)
|
||||
|
||||
Reference in new issue
Block a user