package com.marvinelsen.willow.domain

import java.sql.DriverManager
import kotlin.time.measureTimedValue

const val JDBC_CONNECTION_STRING = "jdbc:sqlite:dictionary.db"

fun main() {
    val connection = DriverManager.getConnection(JDBC_CONNECTION_STRING).apply {
        autoCommit = false
    }

    val sqliteDictionary = SqliteDictionary(connection)
    val (searchResults, time) = measureTimedValue {
        sqliteDictionary.search("柳", SearchMode.TRADITIONAL)
    }
    val (shang, time2) = measureTimedValue {
        sqliteDictionary.search("上", SearchMode.TRADITIONAL).first()
    }
    val (shangWords, time3) = measureTimedValue {
        sqliteDictionary.findWordsContaining(shang)
    }
    println(searchResults)
    println(shangWords)
    println(time)
    println(time2)
    println(time3)
}
