TestDB: initial commit.
commit
c2f531bae4
|
@ -0,0 +1,5 @@
|
|||
/docs/
|
||||
/lib/
|
||||
/bin/
|
||||
/.shards/
|
||||
*.dwarf
|
|
@ -0,0 +1,3 @@
|
|||
# test-db
|
||||
|
||||
Simple database tests to compare DODB to SQL (Postgres).
|
|
@ -0,0 +1,21 @@
|
|||
name: test-db
|
||||
version: 0.1.0
|
||||
|
||||
authors:
|
||||
- Philippe PITTOLI <karchnu@karchnu.fr>
|
||||
|
||||
targets:
|
||||
psql-query-one:
|
||||
main: src/psql-query-one.cr
|
||||
# test-db:
|
||||
# main: src/test-db.cr
|
||||
|
||||
dependencies:
|
||||
dodb:
|
||||
git: ../dodb.cr/
|
||||
pg:
|
||||
github: will/crystal-pg
|
||||
|
||||
crystal: '>= 1.12.1'
|
||||
|
||||
license: ISC
|
|
@ -0,0 +1,2 @@
|
|||
require "spec"
|
||||
require "../src/test-db"
|
|
@ -0,0 +1,9 @@
|
|||
require "./spec_helper"
|
||||
|
||||
describe Test::Db do
|
||||
# TODO: Write tests
|
||||
|
||||
it "works" do
|
||||
false.should eq(true)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,25 @@
|
|||
require "db"
|
||||
require "pg"
|
||||
|
||||
nb_run = ARGV[1].to_i rescue 1000
|
||||
|
||||
DB.open(ENV["DATABASE_URL"]) do |db|
|
||||
i = 0
|
||||
while i < nb_run
|
||||
i += 1
|
||||
t1 = Time.monotonic
|
||||
data = db.query_one(ARGV[0], &.read)
|
||||
t2 = Time.monotonic
|
||||
elapsed_time = t2 - t1
|
||||
pp! elapsed_time, data
|
||||
end
|
||||
end
|
||||
|
||||
# PSQL_CONNECTION_STRING = "postgres://user:pass@host:port/db_name?option1=a&option2=b"
|
||||
#PSQL_CONNECTION_STRING = "postgres://coucou:LOOKATMYPASS@host:port/db_name"
|
||||
|
||||
#DB.open(PSQL_CONNECTION_STRING) do |db|
|
||||
# # TODO
|
||||
# elapsed_time = Time.measure do
|
||||
# end
|
||||
#end
|
Loading…
Reference in New Issue