From 27662f99b06e1444dc0807b22e3ab2f191de6d8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 14 Nov 2020 13:18:21 +0100 Subject: [PATCH] [skip travis] profile date parsing --- .../GRDBProfiling/AppDelegate.swift | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/Tests/Performance/GRDBProfiling/GRDBProfiling/AppDelegate.swift b/Tests/Performance/GRDBProfiling/GRDBProfiling/AppDelegate.swift index 2c605702d..e3454b23b 100644 --- a/Tests/Performance/GRDBProfiling/GRDBProfiling/AppDelegate.swift +++ b/Tests/Performance/GRDBProfiling/GRDBProfiling/AppDelegate.swift @@ -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)