Commit c3091791 authored by cznic's avatar cznic

QL tool: Add -t for measuring wall time consumed.

parent 9987186a
......@@ -7,10 +7,10 @@
//TODO verify there's a graceful failure for a 2G+ blob on a 32 bit machine.
// Package ql is a pure Go embedded (S)QL database.
// Package ql implements a pure Go embedded SQL database engine.
//
// QL is a SQL-like language. It is less complex and less powerful than SQL
// (whichever specification SQL is considered to be).
// QL is a member of the SQL family of languages. It is less complex and less
// powerful than SQL (whichever specification SQL is considered to be).
//
// Change list
//
......
......@@ -3,7 +3,7 @@
//TODO Put your favorite license here
// yacc source generated by ebnf2y[1]
// at 2015-05-29 16:54:37.147627427 +0200 CEST
// at 2015-05-31 12:59:36.467988124 +0200 CEST
//
// $ ebnf2y -o ql.y -oe ql.ebnf -start StatementList -pkg ql -p _
//
......
......@@ -28,6 +28,8 @@
// If no non flag arguments are present, ql reads from stdin.
// The list is wrapped into an automatic transaction.
//
// -t Report and measure time to execute, including creating/opening and closing the DB.
//
// Example:
//
// $ ql 'create table t (i int, s string)'
......@@ -58,6 +60,7 @@ import (
"regexp"
"sort"
"strings"
"time"
"github.com/cznic/ql"
)
......@@ -86,8 +89,16 @@ func do() (err error) {
oFlds := flag.Bool("fld", false, "Show recordset's field names.")
oSchema := flag.String("schema", "", "If non empty, show the CREATE statements of matching tables and exit.")
oTables := flag.String("tables", "", "If non empty, list matching table names and exit.")
oTime := flag.Bool("t", false, "Measure and report time to execute the statement(s) including DB create/open/close.")
flag.Parse()
t0 := time.Now()
if *oTime {
defer func() {
fmt.Fprintf(os.Stderr, "%s\n", time.Since(t0))
}()
}
db, err := ql.OpenFile(*oDB, &ql.Options{CanCreate: true})
if err != nil {
return err
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment