Sha256: 1f1c4bd152f2393a7598cea4d7678aaf9030743009137840618f0a4b772e32d8

Contents?: true

Size: 828 Bytes

Versions: 1

Compression:

Stored size: 828 Bytes

Contents

#!/usr/bin/env ruby

require 'pg_graph'
require 'shellopts'

SPEC = "
  @ Demo

  Demonstration of reading and writing a database. Has actually nothing to do
  with postspec

  -r,reflections=EFILE @ Reflections file

  -- DATABASE"

def timeit(label = nil, &block)
  t0 = Time.now
  r = yield
  dt = Time.now - t0
  if dt < 1
    puts "#{label}: #{(1000.0 * dt).round(1)}ms"
  else
    puts "#{label}: #{dt.round(1)}s"
  end
  r
end

opts, args = ShellOpts.process(SPEC, ARGV)

database = args.expect(1)

puts "Reading and writing the given database"
indent {
  conn = PgConn.new(database)
  meta = timeit("Meta") { PgMeta.new(conn) }
  type = timeit("Type") { PgGraph::Type.new(meta, opts.reflections) }
  data = timeit("Read data") { PgGraph::Data.new(type, conn) }
  load_data = timeit("Write data") { data.write(conn) }
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
postspec-0.1.1 exe/postspec