Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
e29ddce6
Commit
e29ddce6
authored
Jul 31, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
eae40f9e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
5 deletions
+49
-5
go/zodb/zodbtools/driver.go
go/zodb/zodbtools/driver.go
+49
-5
No files found.
go/zodb/zodbtools/driver.go
View file @
e29ddce6
...
...
@@ -24,7 +24,10 @@ import (
"flag"
"fmt"
"io"
"log"
"os"
"runtime"
"runtime/pprof"
)
// Command describes one zodb subcommand
...
...
@@ -81,6 +84,8 @@ type MainProg struct {
// Main is the main entry point for the program. Call it from main.
func
(
prog
*
MainProg
)
Main
()
{
flag
.
Usage
=
prog
.
usage
cpuprofile
:=
flag
.
String
(
"cpuprofile"
,
""
,
"write cpu profile to `file`"
)
memprofile
:=
flag
.
String
(
"memprofile"
,
""
,
"write memory profile to `file`"
)
flag
.
Parse
()
argv
:=
flag
.
Args
()
...
...
@@ -91,6 +96,33 @@ func (prog *MainProg) Main() {
command
:=
argv
[
0
]
// handle common options
if
*
cpuprofile
!=
""
{
f
,
err
:=
os
.
Create
(
*
cpuprofile
)
if
err
!=
nil
{
log
.
Fatal
(
"could not create CPU profile: "
,
err
)
}
if
err
:=
pprof
.
StartCPUProfile
(
f
);
err
!=
nil
{
log
.
Fatal
(
"could not start CPU profile: "
,
err
)
}
defer
pprof
.
StopCPUProfile
()
}
defer
func
()
{
if
*
memprofile
!=
""
{
f
,
err
:=
os
.
Create
(
*
memprofile
)
if
err
!=
nil
{
log
.
Fatal
(
"could not create memory profile: "
,
err
)
}
runtime
.
GC
()
// get up-to-date statistics
if
err
:=
pprof
.
WriteHeapProfile
(
f
);
err
!=
nil
{
log
.
Fatal
(
"could not write memory profile: "
,
err
)
}
f
.
Close
()
}
}()
// help on a topic
if
command
==
"help"
{
prog
.
help
(
argv
)
...
...
@@ -116,15 +148,27 @@ func (prog *MainProg) usage() {
Usage:
%s command [arguments]
%s
[common-options]
command [arguments]
The commands are:
`
,
prog
.
Summary
,
prog
.
Name
)
// XXX 11 -> max width of cmd.Name
// to lalign commands & help summaries
nameWidth
:=
0
for
_
,
cmd
:=
range
prog
.
Commands
{
if
len
(
cmd
.
Name
)
>
nameWidth
{
nameWidth
=
len
(
cmd
.
Name
)
}
}
for
_
,
topic
:=
range
prog
.
HelpTopics
{
if
len
(
topic
.
Name
)
>
nameWidth
{
nameWidth
=
len
(
topic
.
Name
)
}
}
for
_
,
cmd
:=
range
prog
.
Commands
{
fmt
.
Fprintf
(
w
,
"
\t
%-
11s %s
\n
"
,
cmd
.
Name
,
cmd
.
Summary
)
fmt
.
Fprintf
(
w
,
"
\t
%-
*s %s
\n
"
,
nameWidth
,
cmd
.
Name
,
cmd
.
Summary
)
}
fmt
.
Fprintf
(
w
,
...
...
@@ -133,6 +177,7 @@ The commands are:
Use "%s help [command]" for more information about a command.
`
,
prog
.
Name
)
// XXX +common-options
if
len
(
prog
.
HelpTopics
)
>
0
{
fmt
.
Fprintf
(
w
,
`
...
...
@@ -140,9 +185,8 @@ Additional help topics:
`
)
// XXX 11 -> max width of topic.Name
for
_
,
topic
:=
range
prog
.
HelpTopics
{
fmt
.
Fprintf
(
w
,
"
\t
%-
11s %s
\n
"
,
topic
.
Name
,
topic
.
Summary
)
fmt
.
Fprintf
(
w
,
"
\t
%-
*s %s
\n
"
,
nameWidth
,
topic
.
Name
,
topic
.
Summary
)
}
fmt
.
Fprintf
(
w
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment