Created
December 4, 2023 17:31
-
-
Save igrishaev/996e4e8b207ba2d3c6cec95cd3cd3d87 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns pg.client-test | |
(:import | |
com.github.igrishaev.Connection) | |
(:import | |
java.io.ByteArrayInputStream | |
java.io.ByteArrayOutputStream | |
java.time.Instant | |
java.time.LocalDate | |
java.time.LocalDateTime | |
java.time.LocalTime | |
java.time.OffsetDateTime | |
java.time.OffsetTime | |
java.util.ArrayList | |
java.util.Date | |
java.util.HashMap | |
java.util.concurrent.ExecutionException) | |
(:require | |
[clojure.data.csv :as csv] | |
[clojure.java.io :as io] | |
[clojure.string :as str] | |
[clojure.test :refer [deftest is use-fixtures testing]] | |
[pg.client :as pg] | |
[pg.client.as :as as] | |
[pg.client.conn :as conn] | |
[pg.client.func :as func] | |
[pg.honey :as pgh] | |
[pg.integration :as pgi :refer [*CONFIG*]] | |
[pg.json] | |
[pg.oid :as oid])) | |
(comment | |
(require '[next.jdbc :as jdbc]) | |
(require '[next.jdbc.result-set :as jdbc.rs]) | |
;; 8000.900308 | |
(time | |
(let [conn (jdbc/get-connection {:dbtype "postgres" | |
:port 15432 | |
:dbname "ivan" | |
:user "ivan" | |
:password "ivan"})] | |
(jdbc/execute! conn ["select * from generate_series(1,500000)"] | |
{:as jdbc.rs/as-unqualified-maps}) | |
nil)) | |
(def ^Connection -c (pg/connect {:port 15432 | |
:user "ivan" | |
:password "ivan" | |
:database "ivan"})) | |
(def ^Connection -c | |
(new Connection | |
"127.0.0.1" | |
(int 15432) | |
"ivan" | |
"ivan" | |
"ivan")) | |
;; (.sendStartupMessage -c) | |
;; (.readMessage -c) | |
;; (.close -c) | |
(time | |
(do | |
(.query -c "select * from generate_series(1,500000)") | |
nil)) | |
;; 11387.622 | |
(time | |
(loop [i 0] | |
(let [msg (.readMessage -c)] | |
(when-not (instance? com.github.igrishaev.msg.ReadyForQuery msg) | |
(recur (inc i)))))) | |
#_ | |
(time | |
(do | |
(pg.client.flow/interact -c :query {}) | |
nil)) | |
(time | |
(do | |
(Flow/interact -c "query") | |
nil)) | |
(type -c) | |
(Flow/isEnough 42 "query") | |
) | |
(use-fixtures :each pgi/fix-multi-version) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment